jsp表单制作,要求有Javascript验证
发布网友
发布时间:2022-05-05 17:55
我来回答
共1个回答
热心网友
时间:2022-06-27 21:21
$$("year").onblur = function(){
var check = /^([1-2][0-9][0-9][0-9])-(0?[1-9]|1[0-2])-((0?[1-9])|((1|2)[0-9])|30|31)$/
if(check.test($$("year").value)){
$$("yearWarning").innerHTML="";
}else
$$("yearWarning").innerHTML="请输入正确年份如2012-12-12";
$$("yearWarning").style.color = "red";
//$$("year").className += " err_tips"
}
$$("sp").onblur = function(){
var check = /^[0-9]*$/
if(check.test($$("sp").value)){
$$("spWarning").innerHTML="";
}else
$$("spWarning").innerHTML="请输入正确整数数字";
$$("spWarning").style.color = "red";
//$$("year").className += " err_tips"
}
$$("ep").onblur = function(){
var check = /^[0-9]*$/
if(check.test($$("ep").value)){
$$("epWarning").innerHTML="";
}else
$$("epWarning").innerHTML="请输入正确整数数字";
$$("epWarning").style.color = "red";
//$$("year").className += " err_tips"
}
$$("amount").onblur = function(){
var check = /^[0-9]*$/
if(check.test($$("amount").value)){
$$("amountWarning").innerHTML="";
}else
$$("amountWarning").innerHTML="请输入正确数字";
$$("amountWarning").style.color = "red";
//$$("year").className += " err_tips"
}
$$("ekwords").onblur = function(){
var check = /^[\w-\.]*$/i
if(check.test($$("ekwords").value)){
$$("ekwordsWarning").innerHTML="";
}else
$$("ekwordsWarning").innerHTML="请输入英文关键字";
$$("ekwordsWarning").style.color = "red";
//$$("year").className += " err_tips"
}
$$("scifat").onblur = function(){
var check = /(([0-9]+\.[0-9]*)+$)|[0-9]+$/
if(check.test($$("scifat").value)){
$$("scifatWarning").innerHTML="";
}else
$$("scifatWarning").innerHTML="请输入整数或浮点数";
$$("scifatWarning").style.color = "red";
//$$("year").className += " err_tips"
}
$$("scimtfact").onblur = function(){
var check = /(([0-9]+\.[0-9]*)+$)|[0-9]+$/
if(check.test($$("scimtfact").value)){
$$("scimtfactWarning").innerHTML="";
}else
$$("scimtfactWarning").innerHTML="请输入整数或浮点数";
$$("scimtfactWarning").style.color = "red";
//$$("year").className += " err_tips"
}
$$("kmail").onblur = function(){
var check = /(([0-9]+\.[0-9]*)+$)|[0-9]+$/
if(check.test($$("kmail").value)){
$$("kmailWarning").innerHTML="";
}else
$$("kmailWarning").innerHTML="请输正确邮箱";
$$("kmailWarning").style.color = "red";
//$$("year").className += " err_tips"
}
好好看看吧。。。。但不完全哈。。。