html怎么验证表单 一段表单JS验证代码
一段表单JS验证代码
<script Language= JavaScript >function FormCheck(theform){if (theform hybz value == ){alert( 请选择注册类别! );theform hybz focus();return (false);}if (theform user value == ){alert( 请填写您的用户名! );theform user focus();return false;}var filter=/^\s*[ A Za z _ ]{ }\s*$/;if (!filter test(theform user value)) {alert( 用户名填写不正确 请重新填写!可使用的字符为(A Z a z _ )长度不小于 个字符 不超过 个字符 注意不要使用空格 );theform user focus();theform user select();return false;}if (theform pass value == ){alert( 请填写您的密码! );theform pass focus();return false;}if(nfirmPassword value== ){alert( 请输入您的确认密码! );nfirmPassword focus();return false;}var filter=/^\s*[ A Za z _ ]{ }\s*$/;if (!filter test(theform pass value)) {alert( 密码填写不正确 请重新填写!可使用的字符为(A Z a z _ )长度不小于 个字符 不超过 个字符 注意不要使用空格 );theform pass focus();theform pass select();return false;}if (theform pass value!=nfirmPassword value ){alert( 两次填写的密码不一致 请重新填写! );theform pass focus();theform pass select();return false;}if (theform question value == ){alert( 请输入密码提示问题! );theform question focus();return (false);}if (theform answer value == ){alert( 请输入密码提示答案! );theform answer focus();return (false);}if (theform name value == ){alert( 请输入您的姓名! );theform name focus();return (false);}if (theform sf value == ){alert( 请选择区域! );theform sf focus();return (false);}if (theform city value == ){alert( 请选择城镇名! );theform city focus();return (false);}if (theform qymc value == ){alert( 请输入您的公司名称! );theform qymc focus();return (false);}if (theform qylb value == ){alert( 请选择您的单位性质! );theform qylb focus();return (false);}if (theform address value == ){alert( 请输入您的联系地址! );theform address focus();return (false);}if (theform post value == ){alert( 请输入邮政编码! );theform post focus();return (false);}if (theform phone value == ){alert( 请输入您的联系电话! );theform phone focus();return (false);}if (theform email value == ){alert( 请输入您的电子邮件地址! );theform email focus();theform email select();return false;}var filter=/@/;if (!filter test(theform email value)) {alert( 邮件地址不正确 请重新填写! );theform email focus();theform email select();return false;}<! theform submit() >}</script>

调用代码 表单提交时用下列代码调用
lishixinzhi/Article/program/net/201311/13329