87,909
社区成员
发帖
与我相关
我的任务
分享
var bResult = null;
function check() {
{
bResult = IsChinaId()
}
if(!bResult) {
// ...
}
<input type="text" id="tb1"/><span id="SPANtb1"></span>
<input type="text" id="tb2"/><span id="SPANtb2"></span>
<input type="button" onclick="return chkForm();">
function chkForm()
{
if(ckhvale("tb1","","身份证不能为空")&&ckhvale("tb2","","用户名不能为空"))
{
return false;
}
return true;
}
ckhvale(objID,value,msg)
{
obj=document.getElementById(objID);
objval=obj.value;
objspan=document.getElementById("SPAN"+objID);
if(objval==value)
{
objspan.HTML="<font color=red>"+msg+"</font>";
obj.focus();
return true;
}
return false;
}
<script type="text/javascript">
function check() {
if (document.reg.nid.value == "") {
alert ("请输入您登陆的身份证号!");
document.reg.nid.focus();
return false;
}
if (document.reg.username.value == "") {
alert ("请输入您登陆的用户名!");
document.reg.username.focus();
return false;
}
return true;
}
</script>
<form id="reg" name="reg" method="post" action="">
<table>
<tr>
<td> <input type="text" name="nid" id="uid_" />填入身份证号 </td>
<td> <input type="text" name="username" id="username_" />填入姓名 </td>
<td> <input type="submit" name="tijiao" id="tijiao" value="提交" onclick="return check();" /> </td>
</tr>
</table>
</form>