87,901
社区成员
发帖
与我相关
我的任务
分享
<table width="90%" border="0" align="center" cellpadding="1">
<tr>
<td class="auto-style6" style="text-decoration: underline">Cations</td>
<td class="auto-style3"><asp:RadioButton runat="server" ID="C_V1" Text="mg/L" GroupName="1" onClick="radionCheck(this)"></asp:RadioButton></td>
<td class="auto-style4"><asp:RadioButton runat="server" ID="C_V2" Text="ppmm CaCo3" GroupName="1" onClick="radionCheck(this)"></asp:RadioButton></td>
<td class="auto-style5"><asp:RadioButton runat="server" ID="C_V3" Text="meg/L" GroupName="1" onClick="radionCheck(this)"></asp:RadioButton></td>
<td width="672"><asp:RadioButton runat="server" ID="C_V4" Text="mmol/L" GroupName="1" onClick="radionCheck(this)"></asp:RadioButton></td>
</tr>
<tr>
<td align="right" class="auto-style6">Ammonium(NH4+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_1" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4">
<asp:TextBox ID="B_1" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5">
<asp:TextBox ID="C_1" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td>
<asp:TextBox ID="D_1" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Potassium(K+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_2" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_2" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_2" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_2" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Sodium(Na+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_3" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_3" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_3" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_3" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Magnesium(Mg2+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_4" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_4" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_4" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_4" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6" style="color: #FF0000">*Calcium(Ca2+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_5" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_5" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_5" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_5" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Strontium(Sr2+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_6" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_6" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_6" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_6" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Barium(Ba2+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_7" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_7" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_7" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_7" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Fe +x</td>
<td class="auto-style3">
<asp:TextBox ID="A_8" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_8" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_8" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_8" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Mn +x</td>
<td class="auto-style3">
<asp:TextBox ID="A_9" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_9" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_9" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_9" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Al 3+</td>
<td class="auto-style3">
<asp:TextBox ID="A_10" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_10" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_10" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_10" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
</table>
<script type="text/javascript">
function radionCheck(radioID) {
if (document.getElementById("C_V1").checked == true) {
document.getElementById('A_1').disabled = false;
document.getElementById('B_1').disabled = true;
document.getElementById('C_1').disabled = true;
document.getElementById('D_1').disabled = true;
document.getElementById('B_2').disabled = true;
document.getElementById('C_2').disabled = true;
}
else if (document.getElementById("C_V2").checked == true) {
}
else if (document.getElementById("C_V3").checked == true) {
}
else (document.getElementById("C_V4").checked == true) {
}
}
</script>
<script src="js/jquery-1.2.6.min.js" type="text/javascript"></script>
<script src="js/jquery.numberformatter.js" type="text/javascript"></script>
<script src="js/jquery.alphanumeric.plus.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$(".decimal").decimal();
$(".numeric").numeric();
$.fn.format.defaults.locale = "us";
$.fn.parse.defaults.locale = "us";
$("#salary").blur(function(){
$(this).format({format:"###.000"});
});
});
</script>
我用这个来做验证挺好的,就是只能定义一个实例,怎么才能用到多个textbox上呢?而且还缺个弹出窗口提示功能,有没人办法搞定啊?大神! <script type="text/javascript">
function radionCheck(radioID) {
for(i=1;i<=10;i++)
{
document.getElementById('A_'+i).disabled = true;
document.getElementById('B_'+i).disabled = true;
document.getElementById('C_'+i).disabled = true;
document.getElementById('D_'+i).disabled = true;
document.getElementById(radioID.id + '_' + i).disabled = false;
}
}
</script>
<script>
function radionCheck(rb) {
var cellIndex = rb.parentNode.cellIndex, input = rb.parentNode.parentNode.parentNode.getElementsByTagName('input');
for (var i = 0, j = input.length; i < j; i++)
input[i].disabled = input[i].type == 'text' && input[i].parentNode.cellIndex != cellIndex;
}
</script>
<table width="90%" border="0" align="center" cellpadding="1"><tbody>
<tr>
<td class="auto-style6" style="text-decoration: underline">Cations</td>
<td class="auto-style3"><asp:RadioButton runat="server" ID="C_V1" Text="mg/L" GroupName="1" onClick="radionCheck(this)"></asp:RadioButton></td>
<td class="auto-style4"><asp:RadioButton runat="server" ID="C_V2" Text="ppmm CaCo3" GroupName="1" onClick="radionCheck(this)"></asp:RadioButton></td>
<td class="auto-style5"><asp:RadioButton runat="server" ID="C_V3" Text="meg/L" GroupName="1" onClick="radionCheck(this)"></asp:RadioButton></td>
<td width="672"><asp:RadioButton runat="server" ID="C_V4" Text="mmol/L" GroupName="1" onClick="radionCheck(this)"></asp:RadioButton></td>
</tr>
<tr>
<td align="right" class="auto-style6">Ammonium(NH4+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_1" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4">
<asp:TextBox ID="B_1" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5">
<asp:TextBox ID="C_1" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td>
<asp:TextBox ID="D_1" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Potassium(K+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_2" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_2" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_2" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_2" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Sodium(Na+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_3" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_3" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_3" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_3" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Magnesium(Mg2+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_4" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_4" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_4" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_4" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6" style="color: #FF0000">*Calcium(Ca2+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_5" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_5" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_5" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_5" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Strontium(Sr2+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_6" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_6" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_6" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_6" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Barium(Ba2+)</td>
<td class="auto-style3">
<asp:TextBox ID="A_7" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_7" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_7" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_7" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Fe +x</td>
<td class="auto-style3">
<asp:TextBox ID="A_8" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_8" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_8" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_8" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Mn +x</td>
<td class="auto-style3">
<asp:TextBox ID="A_9" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_9" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_9" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_9" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr>
<tr>
<td align="right" class="auto-style6">Al 3+</td>
<td class="auto-style3">
<asp:TextBox ID="A_10" runat="server" MaxLength="22" value="0.000"></asp:TextBox>
</td>
<td class="auto-style4"> <asp:TextBox ID="B_10" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td class="auto-style5"> <asp:TextBox ID="C_10" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
<td><asp:TextBox ID="D_10" runat="server" MaxLength="22" value="0.000"></asp:TextBox></td>
</tr></tbody>
</table>
</form>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$(function(){
$('input[name="sel"]').click(function(){
var col_index=0;
if(this.checked)
{
col_index=$(this).parents("td").index();
$(this).parents("tr").nextAll("tr").find("td").each(function(index, element) {
if($(this).index()==col_index)
$(this).find("input[type='text']").attr("disabled",false);
else
$(this).find("input[type='text']").attr("disabled",true);
});;
}
});
})
</script>
</head>
<body>
<table>
<tr>
<td>Cations</td>
<td><input type="radio" name="sel" id="sel_1"/><label for="sel_1">mg/L</label></td>
<td><input type="radio" name="sel" id="sel_2"/><label for="sel_2">ppmm CaCo3</label></td>
<td><input type="radio" name="sel" id="sel_3"/><label for="sel_3">meg/L</label></td>
<td><input type="radio" name="sel" id="sel_4"/><label for="sel_4">mmol/L</label></td>
</tr>
<tr>
<td>Ammonium(NH4+)</td>
<td><input type="text" /></td>
<td><input type="text" /></td>
<td><input type="text" /></td>
<td><input type="text"/></td>
</tr>
<tr>
<td>Potassium(K+)</td>
<td><input type="text" /></td>
<td><input type="text" /></td>
<td><input type="text" /></td>
<td><input type="text"/></td>
</tr>
</table>
</body>
</html>
<table width="90%" border="0" align="center" cellpadding="1">
<tr>
<td class="auto-style6" style="text-decoration: underline">Cations</td>
<td class="auto-style3"><input type="radio"/></td>
<td class="auto-style4"><input type="radio"/></td>
<td class="auto-style5"><input type="radio"/></td>
<td width="672"><input type="radio"/></td>
</tr>
<tr>
<td align="right" class="auto-style6">Ammonium(NH4+)</td>
<td class="auto-style3">
<input type="text"/>
</td>
<td class="auto-style4"> <input type="text"/>/td>
<td class="auto-style5"> <input type="text"/></td>
<td> <input type="text"/></td>
</tr>
<tr>
<td align="right" class="auto-style6">Potassium(K+)</td>
<td class="auto-style3">
<input type="text"/>
</td>
<td class="auto-style4"> <input type="text"/></td>
<td class="auto-style5"> <input type="text"/></td>
<td> <input type="text"/></td>
</tr>
</table>
$('table input[type=radio]').click(function(){
$('table input[type=text]').attr('disabled',true);var i=$('table input[type=radio]').index(this);$('table td:nth-child(6n+'+(i+2)+') input').attr('disabled',false);
})<tr>
<td class="auto-style6" style="text-decoration: underline">Cations</td>
<td class="auto-style3"><asp:RadioButton runat="server" ID="A" Text="mg/L" GroupName="1" onClick="radionCheck(this)"></asp:RadioButton></td>
<td class="auto-style4"><asp:RadioButton runat="server" ID="B" Text="ppmm CaCo3" GroupName="1" onClick="radionCheck(this)"></asp:RadioButton></td>
<td class="auto-style5"><asp:RadioButton runat="server" ID="C" Text="meg/L" GroupName="1" onClick="radionCheck(this)"></asp:RadioButton></td>
<td width="672"><asp:RadioButton runat="server" ID="D" Text="mmol/L" GroupName="1" onClick="radionCheck(this)"></asp:RadioButton></td>
</tr>
<script type="text/javascript">
function radionCheck(radioID) {
alert(radioID);
for(i=1;i<10;i++)
{
document.getElementById('A_' + i).disabled = true;
document.getElementById('B_'+i).disabled = true;
document.getElementById('C_'+i).disabled = true;
document.getElementById('D_' + i).disabled = true;
document.getElementById(radioID + '_' + i).disabled = false;
}
}
</script>
问题来了,怎么能传递到JS里RadioButton的ID号呢?<asp:TextBox ID="A_1" runat="server" MaxLength="22" value="0.000" onblur="validate(this)"></asp:TextBox>
<script type="text/javascript">
function validate(tt){
var val=tt.value;
var reg=/^\d+(.\d{1,3})?$/;
if(!reg.test(val)){
alert("只能输入数字(最多三位小数)!");
tt.select()
return false;
}
}
</script>
要不你的正则也有问题,输入1.的时候也不满足你的正则了。。其实用户还会继续输入什么的<script type="text/javascript">
function validate(tt){
var val=tt.value;
//var reg=/^(-?\d*)\.?\d{1,3}$/;
var reg=/^\d+(.\d{1,3})?$/;
if(!reg.test(val)){
alert("只能输入数字(最多三位小数)!");
event.keyCode=0;
document.getElementById(tt.id).focus();
return false;
}
//alert("good");
return true;
}
</script>
<asp:TextBox ID="A_1" runat="server" MaxLength="22" value="0.000" onkeypress="validate(this)" onafterpaste="validate(this)"></asp:TextBox>
这样不行,我想要的结果是弹出提示,无效的输入被直接过滤,这个虽然弹出了但还能输入进去。