jQuery Form Validation Plug in Resolves of Recommendation

  • 2021-07-04 18:06:07
  • OfStack

1: Plug-ins

(1) Validform_v5.3.1_min.js Validform_Datatype. js

(2) Website: http://validform.rjboy.cn

There are demo and plug-in download links on this website.

2: General Verification

(1) Validform_Datatype. js


/*
Validform datatype extension
By sean during December 8, 2012 - February 20, 2013
For more information, please visit http://validform.rjboy.cn
 Extend the following types: 
date Matching date 
zh Matching Chinese Characters 
dword Matching double-byte characters 
money Matching Currency Types 
ipv4 : Matching ipv4 Address 
ipv6 : Matching ipv6 Address 
num Matching numeric type 
qq : Matching qq Number 
unequal The current value cannot be equal to the detected value, for example, it can be used to detect that the new password cannot be compared with the old password 1 Sample 
notvalued The current value cannot contain the specified value, for example, the password cannot contain the detection of user name, etc. 
min How many items are selected at least in the multi-check box 
max Maximum number of multiple check boxes 
byterange: Judge the length of characters, and count two characters in Chinese 
numrange : Determine the value range, such as less than 100 Greater than 10 Number between 
daterange : Determine the date range 
idcard : Strictly verify the ID number 
*/

(2) Validform v 5.3. 1


var tipmsg = {
tit : " Prompt information ",
w : {
"*" : " Can't be empty! ",
"*6-16" : " Please fill out 6 To 16 Bit arbitrary character! ",
"n" : " Please fill in the numbers! ",
"n6-16" : " Please fill out 6 To 16 Bit number! ",
"s" : " You cannot enter special characters! ",
"s6-18" : " Please fill out 6 To 18 Bit character! ",
"p" : " Please fill in the zip code! ",
"m" : " Please fill in the mobile phone number! ",
"e" : " The mailbox address format is wrong! ",
"url" : " Please fill in the website address! ",
"w1" : " You must enter a character beginning with a letter, which can be numeric and underlined "
},
def : " Please fill in the correct information! ",
undef : "datatype Undefined! ",
reck : " The content entered twice does not 1 To! ",
r : " Passed the information verification! ",
c : " Detecting information … ",
s : " Please { Fill in | Select }{0| Information } ! ",
v : " The information has not been verified, please wait … ",
p : " Submitting data … "
}

(3) Use


<input name="startTime" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width: 150px"
value="" datatype="date" nullmsg=" Start time cannot be empty " errormsg=" The date format is incorrect !" >

Add the attribute datatype to input. nullmsg is the prompt when it is empty, and errormsg is the prompt when it does not satisfy the datatype attribute format.

3: Special validation

(1) Special verification means that when the method provided in js cannot meet the actual requirements, it is necessary to write the corresponding datatype to meet the requirements.

For example, the end time is not less than the start time:


$(".registerform").Validform({
datatype:{
"enddate":function(gets,obj,curform,regxp){
/* Parameter gets Is the value of the obtained form element, 
obj For the current form element, 
curform For the currently validated form, 
regxp For built-in 1 References to regular expressions. */
var reg1=regxp["date"],
startdate=curform.find("[name=startTime]").val(),
enddate=gets;
if(reg1.test(enddate)&&startdate<enddate){return true;}
return false;
} 
},
ajaxPost:true
}); 

Related articles: