盘绰网教程:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

用 JSP 在客户端生成 JavaScript 代码来完成表单校验

时间:2024/12/29作者:未知来源:盘绰网教程人气:


[摘要]" + "\n" +"fucCheckLength(document."+formName+"."+inputName+&quo...
" + "\n" +
"fucCheckLength(document."+formName+"."+inputName+".value)>"+MaxLength+") {" + "\n" +
"alert(\""+errorMsg+".\");" + "\n" +
"document."+formName+"."+inputName+".focus();" + "\n" +
"return(false);" + "\n" +
"}" + "\n\n";
}

/***************************************************************************\
 *public: check the email
 *检查录入框值是否是正确的EMAIL格式
\***************************************************************************/
public void emailCheck(String inputName, String errorMsg){
this.errorCheckStr +=
"if(chkemail(document."+formName+"."+inputName+".value) == 0) {" + "\n" +
"alert(\""+errorMsg+".\");" + "\n" +
"document."+formName+"."+inputName+".focus();" + "\n" +
"return(false);" + "\n" +
"}" + "\n\n";
}

/***************************************************************************\
 *public: check the telephone number
 *检查录入框值是否是电话号码
\***************************************************************************/
public void telCheck(String inputName, String errorMsg){
this.errorCheckStr +=
"if(fucCheckTEL(document."+formName+"."+inputName+".value) == 0) {" + "\n" +
"alert(\""+errorMsg+".\");" + "\n" +
"document."+formName+"."+inputName+".focus();" + "\n" +
"return(false);" + "\n" +
"}" + "\n\n";
}

/***************************************************************************\
 *public: check if the input value contian the divfered string
 *检查录入框值是否是包含给定字串
\***************************************************************************/
public void stringCheck(String inputName, String errorMsg, String string){
this.errorCheckStr +=
"if(document."+formName+"."+inputName+".value.indexOf(\""+string+"\") != 0) {" + "\n" +
"alert(\""+errorMsg+".\");" + "\n" +
"document."+formName+"."+inputName+".focus();" + "\n" +
"return(false);" + "\n" +
"}" + "\n\n";
}

/***************************************************************************\
 *public: check if the input value contain the denyed string
 *检查录入框值是否是包含给禁止的字串
\***************************************************************************/
public void denyStrCheck(String inputName, String errorMsg, String string){
this.errorCheckStr +=
"if (document."+formName+"."+inputName+".value.length == 0

关键词:    JSP  在客户端生成  JavaScript  代码来完成表单校验





Copyright © 2012-2018 盘绰网教程(http://www.panchuo.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版