$(document).ready(function(){ // 初始化 $.formvalidator.initconfig({ formid:'msgform', debug:true, alertmessage:0, onsuccess:function(){ erro:1; adform.submit(); }, onerror:function(){ erro:false; alert("an error, please see the web page tips"); return false; } }); // 验证title $("#title").formvalidator({ onshow:"please enter the title", onfocus:"2-20 charactors", oncorrect:"correct input" }).inputvalidator({ min:2, max:40, onerror:"input is not standardized", empty:{ leftempty:false, rightempty:false, emptyerror:"can not have spaces" } }); // username $("#username").formvalidator({ onshow:"please enter the contact name,less than 20 characters", onfocus:"please enter the contact name", oncorrect:"correct input" }).inputvalidator({ min:2, max:20, emptyerror:"can not have spaces" }); // phone $("#phone").formvalidator({ onshow:"please enter the contact phone", onfocus:"please enter the contact phone", oncorrect:"correct input" }).regexvalidator({ regexp:'mobile', datatype:'enum', onerror:'format error' }); // email $("#email").formvalidator({ onshow:"please enter the contact email", onfocus:"please enter the contact email", oncorrect:"correct input" }).regexvalidator({ regexp:'email', datatype:'enum', onerror:'format error' }); // qq $("#qq").formvalidator({ empty:true, onshow:"please enter the contact qq", onfocus:"please enter the contact qq", oncorrect:"correct input" }).regexvalidator({ regexp:'qq', datatype:'enum', onerror:'format error' }); // 验证码 $("#yzm").formvalidator({ onshow:"please enter the verification code", onfocus:"please enter the verification code", oncorrect:"correct input" }).inputvalidator({ min:4, max:4, emptyerror:"can not have spaces" }); // content $("#content").formvalidator({ onshow:"please enter the content", onfocus:"please enter the content", oncorrect:"correct input" }).inputvalidator({ min:2, max:800, emptyerror:"can not have spaces" }); });