EasyUI Forum
March 29, 2024, 04:16:09 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to check all fields required are written?  (Read 4305 times)
Don_Juan
Newbie
*
Posts: 20


View Profile
« on: February 20, 2018, 03:26:09 AM »

Hi,
exist a function or similar that allow me to check all fields required are written?
My fields are different from each other (combobox, validatebox,...), but almost all, have required=true  as inside option.
If the check is ok ,proceed to write, otherwise expose a allert message when i click a linkbutton (to save information) (I Want to check at the end).

I thought about this solution:
  • Scroll through all the elements by checking if required ! = Undefined
  • Check if the field is written.(if != Undefined)

Code:
var rows = $('#details').propertygrid('getChanges');
for(var i=0; i<rows.length; i++){
   if(rows[i].hasOwnProperty('editor')) {
      if(rows[i].editor.options.hasOwnProperty('required')) {
         if(rows[i].editor.options.required && (rows[i].value==""))
            console.log("Required, without value! ALLERT!!!!");
         else
            console.log("Requested and completed");
      } else
         console.log("I do not care");
   } else
      console.log("I do not care");
}

The values I get with $('#details').propertygrid ('getChanges') are:

0: {…}
    editor: {…}
        options: {…}
            missingMessage: "No Field!"
            required: true
            validType: Object { length: […] }
            __proto__: Object { … }
        type: "validatebox"
        __proto__: Object { … }
    group: "Dettagli"
    index: 0
    name: "Name"
    value: ""
    __proto__: Object { … }

.....
5: {…}
    editor: {…}
        options: {…}
            validType: Object { length: […] }
            __proto__: Object { … }
        type: "validatebox"
        __proto__: Object { … }
    group: "Dettagli"
    index: 5
    name: "Tag"
    value: ""
....

Is there another way?
Thanks!
« Last Edit: February 20, 2018, 04:15:20 AM by Don_Juan » Logged
proceno72
Newbie
*
Posts: 39



View Profile
« Reply #1 on: February 20, 2018, 07:23:41 AM »

Are you talking about form fields? If so it'simple; you can try "validate" action of EasyUi form component
Logged
Don_Juan
Newbie
*
Posts: 20


View Profile
« Reply #2 on: February 21, 2018, 01:08:21 AM »

I used a propertygrid into window.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!