表单验证JS生成(DW插件)

表单验证JS生成(DW插件)

下载:
http://www.blogjava.net/Files/quickbomber/Validate_Form.rar

这类的插件见过几个,不过感觉这个还不错,生成简单的验证代码还可以,界面如下:

vf.png

生成的代码如下:

< script language = " Javascript " ><!--
function  VF_editForm() // v2.0
<!-- start_of_saved_settings -->
<!-- type,text,name,address,required, true ,errMsg,请输入正确的地址! -->
<!-- type,text,name,eMail,required, true ,isEmail,errMsg,请输入正确的密码! -->
<!-- type,text,name,passWord,required, true ,errMsg,请输入正确的密码! -->
<!-- type,text,name,userName,required, true ,errMsg,请输入正确的用户名! -->
<!-- end_of_saved_settings -->
    
var  theForm  =  document.editForm;
    
var  emailRE  =   /^ ([a - zA - Z0 - 9_. - ]) + @(([a - zA - Z0 - 9 - ]) + .) + ([a - zA - Z0 - 9 ] { 2 , 4 } ) + $ / ;
    
var  errMsg  =   "" ;
    
var  setfocus  =   "" ;

    
if  (theForm['address'].value  ==   "" ) {
        errMsg 
=   " 请输入正确的地址! " ;
        setfocus 
=   " ['address'] " ;
    }

    
if  ( ! emailRE.test(theForm['eMail'].value)) {
        errMsg 
=   " 请输入正确的邮箱! " ;
        setfocus 
=   " ['eMail'] " ;
    }

    
if  (theForm['passWord'].value  ==   "" ) {
        errMsg 
=   " 请输入正确的密码! " ;
        setfocus 
=   " ['passWord'] " ;
    }

    
if  (theForm['userName'].value  ==   "" ) {
        errMsg 
=   " 请输入正确的用户名! " ;
        setfocus 
=   " ['userName'] " ;
    }

    
if  (errMsg  !=   "" ) {
        alert(errMsg);
        eval(
" theForm "   +  setfocus  +   " .focus() " );
    }

    
else  theForm.submit();
}
// -->
</ script >

调用:

< form  action =""  method ="post"  name ="editForm"  id ="editForm"  onsubmit ="VF_editForm();return false;" >

</ form >


效果图:

ef.png

感觉有用就下载个试试吧~

你可能感兴趣的:(表单验证JS生成(DW插件))