Jqgrid Form Validation Rule parameters Introduction-editrules

Source: Internet
Author: User
Tags jqgrid


 colModel : [ 
    {name:‘id‘,index:‘id‘,width:55,editable:false,editoptions:{readonly:true,size:10}}, 
    {name:‘invdate‘,index:‘invdate‘,width:80,editable:true,editrules:{required:true}} ]

Editrules is a rule that acts as a form validation provided by Jqgrid, similar to a regular expression.
Parameter description:
Edithidden: Valid only in form editing mode, set to True to allow hidden fields to be modified as well.
Required: Sets whether the edit can be empty (if necessary).
Number: Set to True if the input value is not numeric or empty, an error will be added.
Integer: whether integers
MinValue: Maximum Value
MaxValue: Minimum value
Email: Whether it's a legitimate email
URL: Check if it is a legitimate URL address.
Date
Time
Custom: Set to True, it is validated by a custom JS function. The function is defined in Custom_func.
Custom_func: The value passed to the function is one that requires validation of value and the other is the name attribute value defined in Colmodel. The function must return an array, one that is the result of the validation, true or false, and the other is the prompt string for the validation error. such as [False, "Please enter valid value"].
Examples of custom validation:
    <script>
        function Mypricecheck (value, colname) {
         if (value < 0 && value >20)  
            return [False, "Please enter value between 0 and 20"];
        else 
            return [True, ' "];
       }


         jQuery ("#grid_id"). Jqgrid ({
        ...
           Colmodel: [ 
                
               {name: ' Price ', ..., editrules:{custom:true, Custom_func:mypricecheck ...}, Editable:true},
              ...
          ]
        ...
       });
    </script>   



formoptions(only valid in form editing mode), his main function is to reorder the editing elements in the form, and to add some information (for example, some hints or a red *) before editing the element or after editing the element. Indicates that it must be filled out, etc.).
The optional properties are as follows:
Elmprefix: String value, if set, some content will appear after the edit box (possibly HTML content)
Elmsuffix: String value, if set, some content will appear before the edit box (possibly HTML content)
Label: string value, if set, this value will replace the value in Colnames appears as the label of the edit box
Rowpos: A numeric value that determines the position of the element line in the form (relative to the text label again with the Text-label)
Colpos: A numeric value that determines where the element is listed in the form (relative to the label again with the label)
Two edit boxes can have the same Rowpos value, but the Colpos value is different, which puts the two edit boxes in the same row of the form.
Special NOTE: If you set the values for Rowpos and Colpos, it is highly recommended that you set these values for all other editing elements.



Jqgrid Form Validation Rule parameters Introduction-editrules


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.