js验证函数
来源:互联网 发布:pdf解密软件下载 编辑:程序博客网 时间:2024/05/08 16:54
<script language="JavaScript" type="text/javascript">
function submitUpdateInfo(){
if(document.getElementById("username").value==""){
window.alert("昵称不能为空");
form1.username.focus();
return false;
}
if(document.getElementById("username").value.length<2||document.getElementById("username").value.length>20){
window.alert("请正确输入昵称");
form1.username.focus();
return false;
}
//------------- 身份证要是15位的数字,或18位的数字,17位的数字加上最后一位的字符x.
//身份证不为空
nationCard = document.getElementById("nationid").value;
if(nationCard.length!=15 && nationCard.length!=18){
alert("请正确输入15或18位的身份证号码!");
form1.nationid.focus();
form1.nationid.select();
return false;
}
if (nationCard==""||nationCard.length==0){
window.alert("身份证号码不能空");
form1.nationid.focus();
return false;
}
//身份证的格式
if(nationCard.length==15 ){
if (isNaN(nationCard)){
window.alert("15位身份证的输入有误,请正确输入!");
form1.nationid.focus();
form1.nationid.select();
return false;
}
}
if (nationCard.length==18){
subStr = nationCard.substring(0,17);
lastChar = nationCard.substring(17);
if (isNaN(subStr)){
window.alert("18位身份证输入有误,请正确输入!");
form1.nationid.focus();
form1.nationid.select();
return false;
}else if (isNaN(lastChar)){
if(lastChar!="X" && lastChar!="x"){
window.alert("18位的身份证号码最后一位有误!");
form1.nationid.focus();
form1.nationid.select();
return false;
}
}
}
/////---------------------------------身份证检查结束
if(document.getElementById("email").value==""){
window.alert("电子邮件格式错误");
form1.safeemail.focus();
return false;
}
if(document.getElementById("email").value.indexOf('@')==-1||document.getElementById("email").value.indexOf('.')==-1){
window.alert("电子邮件格式错误");
form1.safeemail.focus();
return false;
}
if(document.getElementById("city").value==""){
window.alert("城市不为空");
form1.city.focus();
return false;
}
document.form1.submit();
}
function resetUpdateInfo(){
document.form1.reset();
}
function prePic (visualize){
if (visualize=="myVisualize")
document.getElementById("myVisualizeArea").innerHTML="<img src="+document.form1.myVisualize.value+" width=89 height=67 alt=我的形象>";
if (visualize=="personalVisualize")
document.getElementById("personalVisualizeArea").innerHTML="<img src="+document.form1.personalVisualize.value+" width=89 height=67 alt=我的个性形象>";
}
//设置原来性别的选中状态
document.form1.sex[<%=sexValue%>].checked =true;
</script>
function submitUpdateInfo(){
if(document.getElementById("username").value==""){
window.alert("昵称不能为空");
form1.username.focus();
return false;
}
if(document.getElementById("username").value.length<2||document.getElementById("username").value.length>20){
window.alert("请正确输入昵称");
form1.username.focus();
return false;
}
//------------- 身份证要是15位的数字,或18位的数字,17位的数字加上最后一位的字符x.
//身份证不为空
nationCard = document.getElementById("nationid").value;
if(nationCard.length!=15 && nationCard.length!=18){
alert("请正确输入15或18位的身份证号码!");
form1.nationid.focus();
form1.nationid.select();
return false;
}
if (nationCard==""||nationCard.length==0){
window.alert("身份证号码不能空");
form1.nationid.focus();
return false;
}
//身份证的格式
if(nationCard.length==15 ){
if (isNaN(nationCard)){
window.alert("15位身份证的输入有误,请正确输入!");
form1.nationid.focus();
form1.nationid.select();
return false;
}
}
if (nationCard.length==18){
subStr = nationCard.substring(0,17);
lastChar = nationCard.substring(17);
if (isNaN(subStr)){
window.alert("18位身份证输入有误,请正确输入!");
form1.nationid.focus();
form1.nationid.select();
return false;
}else if (isNaN(lastChar)){
if(lastChar!="X" && lastChar!="x"){
window.alert("18位的身份证号码最后一位有误!");
form1.nationid.focus();
form1.nationid.select();
return false;
}
}
}
/////---------------------------------身份证检查结束
if(document.getElementById("email").value==""){
window.alert("电子邮件格式错误");
form1.safeemail.focus();
return false;
}
if(document.getElementById("email").value.indexOf('@')==-1||document.getElementById("email").value.indexOf('.')==-1){
window.alert("电子邮件格式错误");
form1.safeemail.focus();
return false;
}
if(document.getElementById("city").value==""){
window.alert("城市不为空");
form1.city.focus();
return false;
}
document.form1.submit();
}
function resetUpdateInfo(){
document.form1.reset();
}
function prePic (visualize){
if (visualize=="myVisualize")
document.getElementById("myVisualizeArea").innerHTML="<img src="+document.form1.myVisualize.value+" width=89 height=67 alt=我的形象>";
if (visualize=="personalVisualize")
document.getElementById("personalVisualizeArea").innerHTML="<img src="+document.form1.personalVisualize.value+" width=89 height=67 alt=我的个性形象>";
}
//设置原来性别的选中状态
document.form1.sex[<%=sexValue%>].checked =true;
</script>
- js验证函数
- js常用验证函数
- js常用验证函数
- js验证函数集合
- js 验证函数
- 常用js验证函数
- js验证日期函数
- js验证函数总结
- JS通用表单验证函数
- JS通用表单验证函数-
- JS通用表单验证函数
- JS通用表单验证函数
- JS通用表单验证函数
- JS通用表单验证函数
- js验证函数validate用法
- 常用JS验证函数总结
- 常用JS验证函数大全
- 常用JS验证函数大全
- 在WEBSTART中实现串口通信(WINDOWS版)
- 高质量c++(重载、覆盖、隐藏)
- 开发工具大比拼之Visual C++ VS Delphi(摘自delphi园地)
- 关于vtable系列之一
- 2005 Java 综述&2006 Java 展望(转)
- js验证函数
- 用户控件动态加载PostBack后的问题(转)
- 大学毕业生如何成功应聘高薪IT职位(转)
- 寻找
- ResolveUrl将URL转换为在请求客户端可用的URL(转From MSDN)
- JAVA学习之路:不走弯路,就是捷径(一)
- 成为Eclipse热键高手(转)
- mp3的霍夫曼解码
- JAVA学习之路:不走弯路,就是捷径(二)