Use of the jquery easyui verification box

Source: Internet
Author: User

Accumulation during use for future reference.

How to Use the easyui verification box:
//***************************
Missingmessage: information displayed when not filled
Validtype: for the verification type, see the following example.
Invalidmessage: information displayed when the data type is invalid
Required = "true" Required
Class = "easyui-validatebox" text Verification
Class = "easyui-numberbox" digital verification
*****************************//

0. Call the data verification method
Return $ ("# form1"). Form ('validate ');
 
Example:
<Asp: button id = "btn_save" runat = "server" text = "save" onclick = "btn_save_click" onclientclick = "return $ (" # form1 "). form ('validate'); "/>

1. check whether it is required
Class = "easyui-validatebox" missingmessage = "XXX required"
2. Verify the string length
Class = "easyui-validatebox" missingmessage = "XXX must contain less than 10 characters" validtype = "length []" invalidmessage = "cannot exceed 2 Characters! "
Example:
<Input class = "easyui-validatebox" required = "true" missingmessage = "name must be filled in" size = "10" type = "text" name = "arealname"> </Input>

3. Verify that the number must be between 5.5-20. Precision = "2" indicates that 2 is a decimal number.
Class = "easyui-numberbox" min = "5.5" max = "20" precision = "2" required = "true" missingmessage = "5.5 ~ required ~ Number between 10"
4. The verification date must be yyyy-mm-dd (only editable)
<SCRIPT>
$. FN. datebox. defaults. formatter = function (date ){
Var y = date. getfullyear ();
VaR M = date. getmonth () + 1;
VaR d = date. getdate ();
Return y + '-' + (M <10? '0' + M: m) + '-' + (d <10? '0' + D: d );
};
$. FN. datebox. defaults. parser = function (s ){
If (s ){
VaR A = S. Split ('-');
VaR d = new date (parseint (A [0]), parseint (A [1])-1, parseint (A [2]);
Return D;
} Else {
Return new date ();
}
};
</SCRIPT>
Class = "easyui-datebox" required = "true" missingmessage = "date required" editable = "false"
// If you need to enter another format type, modify the formatter function.

5. The verification must be an email.
Class = "easyui-validatebox" missingmessage = "the email must be filled in" validtype = "email" invalidmessage = "please fill in the correct email format"

6. The time when the page time period determines that name is S1 must be greater than the time when name is S2. S3 must be greater than S2.
<SCRIPT>
$. Extend ($. FN. validatebox. defaults. Rules ,{
Timecheck :{
Validator: function (value, Param ){
VaR S = $ ("input [name =" + Param [0] + "]"). Val ();
// Because the date format is consistent, you can directly compare strings. Otherwise, you need to convert the date. parse (_ date)
Return value> = s;
},
Message: 'invalid data'
}
});
</SCRIPT>
<Input name = "S1" class = "easyui-datebox" required = "true" missingmessage = "date required" editable = "false"> </input>
<Input name = "S2" class = "easyui-datebox" required = "true" validtype = "timecheck ['s1']" invalidmessage = "S1 must be greater than S2" editable =" false "> </input>
<Input name = "S3" class = "easyui-datebox" required = "true" validtype = "timecheck ['s2']" editable = "false"> </input>

7. Submit the inquiry dialog box:
Function confirmbtn (MSG, control ){
$. Messager. Confirm ('confirmed', MSG, function (r ){
If (r ){
_ Dopostback ("ctl00 $ contentph_main $ button1 ","");
// Alert ('A ');
}
});
Return false;
}

Onclientclick = "Return confirmbtn ('OK? ', This );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.