Check if a field is disabled on preSubmit

Check if a field is disabled on preSubmit

wblakencwblakenc Posts: 77Questions: 17Answers: 1
edited August 2017 in Free community support

Hello all,
I was wondering if anyone has discovered a way to check if a field is disabled when preforming client side validation. Basically I have two events that occur:
1) on initEdit I have validation scripts that check which fields should be enabled / disabled based on the data of the row being edited.
2) on preSubmit that checks to ensure that required fields are filled out prior to submission to the server. When doing the preSubmit check, I want to check if a field is both enabled and has a value before submitting the form.

 editor.on('preSubmit', function(e,data,action) {
        var fieldOffice = this.field('fieldOffice');        
        if (! fieldOffice.val() && fieldOffice.disable != true) {
            fieldOffice.error('Field office is required');
        }
          if (this.inError()) {
        return false;
         }
    }); 

I see in the field API that you can programmatically enable/disable a field, but is there anyway to check if one is disabled? something like:

 fieldOffice.isDisabled() 

Am I just missing something?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,195Questions: 1Answers: 10,412 Site admin

    Nope - you aren't - I am. That's an API method that should have been fairly obvious for me to include, but I think this is the first time I've come across that request. I'll add it in. I had hoped to get 1.6.5 out today, but that isn't going to happen now, which is good news here, since I'll get this method in.

    Regards,
    Allan

  • allanallan Posts: 63,195Questions: 1Answers: 10,412 Site admin
    Answer ✓

    Yup - committed now and will be in 1.6.5. The method name is field().enabled() for consistency with API methods that are presented by other extensions.

    Allan

  • wblakencwblakenc Posts: 77Questions: 17Answers: 1

    Allan,
    Wow! Quick response and turn around. I look forward to the next release. I really appreciate it!

This discussion has been closed.