$(document).ready(function(){
$.formValidator.initConfig({formid:"regform",onerror:function(msg){alert(msg)}});
$("#username").formValidator({onshow:"6 - 20 characters (A-Z, a-z, _,-,0-9 only)",onfocus:"6 - 20 characters (A-Z, a-z, _,-,0-9 only)",oncorrect:"right"}).inputValidator({min:6,max:20,onerror:"Please enter a valid username"}).regexValidator({regexp:"^\\w+$",onerror:"Please enter a valid username",oncorrect:"ok"});
$("#password").formValidator({onshow:"6 - 20 characters (A-Z, a-z, _, -,0-9 only)",onfocus:"6 - 20 characters (A-Z, a-z, _, -,0-9 only)",oncorrect:"right"}).inputValidator({min:6,max:20,empty:{leftempty:false,rightempty:false,emptyerror:"Password cannot include space"},onerror:"6 - 20 characters (A-Z, a-z, _, -,0-9 only)"}).regexValidator({regexp:"^\\w+$",onerror:"含有非法字符"});
$("#repassword").formValidator({onshow:"",onfocus:"Please enter your password again",oncorrect:"right"}).inputValidator({min:6,max:20,empty:{leftempty:false,rightempty:false,emptyerror:"Password cannot include space"},onerror:"Passwords are not the same!"}).compareValidator({desid:"password",operateor:"=",onerror:"Passwords are not the same"});
$("#firstname").formValidator({onshow:"Name",onfocus:"Please enter a valid username",oncorrect:"right"}).regexValidator({regexp:"^\\w+$",onerror:"Please enter a valid username",oncorrect:"ok"});
$("#email").formValidator({onshow:" e.g. you@yourcompany.com",onfocus:" e.g. you@yourcompany.com",oncorrect:"right",defaultvalue:"@"}).inputValidator({min:6,max:50,onerror:" Please enter a valid Email Address!"}).regexValidator({regexp:"^([\\w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([\\w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$",onerror:"Please enter a valid Email Address！"});
$("#companyname").formValidator({onshow:"6 - 80 characters",onfocus:" 6 - 80 characters",oncorrect:"right" }).inputValidator({min:6,max:80,onerror:" Please enter a valid Company Name!"});
$("#Tel_country").formValidator({tipid:"teltip",onshow:"Country Code",onfocus:" e.g. 086 ",oncorrect:"right",defaultvalue:"86"}).regexValidator({regexp:"^\\d{2}$",onerror:"Country Code should be two number!"});
$("#Tel_area").formValidator({tipid:"teltip",onshow:"City Code",onfocus:"e.g. 0755",oncorrect:"Right"}).regexValidator({regexp:"^\\d{3,4}$",onerror:"City Code should be three or four numbers!"});
$("#Tel_number").formValidator({tipid:"teltip",onshow:"e.g. 086 - 0571 - 12345678",onfocus:"e.g. 1234567 or 12345678",oncorrect:"right!"}).regexValidator({regexp:"^\\d{7,8}$",onerror:"Phone Number should be seven or eight numbers!"});
$("#postcode").formValidator({onshow:"e.g. 518000",onfocus:"e.g. 518000",onerror:"err",oncorrect:"right" }).inputValidator({ min:6,max:6,onerror:"error"});;
$("#website").formValidator({onshow:"e.g. http://www.theicstock.com",onfocus:"e.g. http://www.theicstock.com",onerror:"err",oncorrect:"right",defaultvalue:"http://"}).regexValidator({regexp:"^http[s]?:\\/\\/([\\w-]+\\.)+[\\w-]+([\\w-./?%&=]*)?$",onerror:"Please enter a valid URL！"});;
});

