Easyui How to use validation boxes

Source: Internet
Author: User

Use the process of an accumulation, for reference.

Easyui How to use the validation box:
//***************************
Missingmessage: Information displayed when not filled in
Validtype: Verification type See example below
Invalidmessage: Information displayed when invalid data type
Required= "true" required
class= "Easyui-validatebox" text validation
Class= "Easyui-numberbox" Digital verification
*****************************//

0. Call data validation 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, verification is required
class= "Easyui-validatebox" missingmessage= "xxx must be filled in"
2. Verify string length
class= "Easyui-validatebox" missingmessage= "xxx must be filled in less than 10 characters" validtype= "length[0,2]" invalidmessage= "cannot exceed 2 characters! "
Example:
<input class= "Easyui-validatebox" required= "true" missingmessage= "name must be filled" size= "type=" text "Name=" Arealname " ></input>

3, verify that the number must be 5.5-20 between precision= "2" means 2 is a decimal
class= "Easyui-numberbox" min= "5.5" max= "2" precision= "true" required= "must fill in the numbers between missingmessage="
4, verification must be date yyyy-mm-dd (can only select not 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 must be filled" editable= "false"
If you need to fill in other format types, please modify the formatter function yourself

5. Verification must be mail
class= "Easyui-validatebox" missingmessage= "mail must be filled in" validtype= "email" invalidmessage= "please fill in the correct message format"

6, the page time period to determine that the name S1 must be greater than the time of name 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 dates are in uniform format, you can directly compare strings otherwise you need Date.parse (_date) to convert
      Return value>=s;
    },
    message: ' Illegal data '
   
   });
</script>
<input name= "S1" class= "Easyui-datebox" required= "true" missingmessage= "date must be filled" 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. Ask the dialog box to submit:
function confirmbtn (msg, control) {
$.messager.confirm (' Ack ', MSG, function (r) {
if (r) {
__doPostBack ("Ctl00$contentph_main$button1", "" ");
Alert (' AA ');
}
});
return false;
}

onclientclick= "Return confirmbtn (' Confirm? ', this);

Easyui How to use validation boxes

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.