hide/disable button if validation errors? - InfoPath Dev
in

InfoPath Dev

hide/disable button if validation errors?

Last post 07-14-2009 09:46 AM by krishna. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-15-2009 06:35 AM

    hide/disable button if validation errors?

    Hi,

    I have a form with a button.  The button has rules that submit to the environment and close the form. 

    If the form has validation errors and the user clicks the button, a rather incomprehensible message is shown such as:

    ===================== 
    Some rules were not applied.

    Click Continue to resume filling out the form. You may want to check your form data for errors.

    Click Start Over to load a new copy of the form.

    Hide error details

    The form cannot be submitted because it contains validation errors. Errors are marked with either a red asterisk (required fields) or a red, dashed border (invalid values).

    Field or group: my:Comments
    Error: Error
    =====================

    A user is going to have no idea what is going on, what they did that is wrong and whether they should continue or start over.

    So, how can I hide or disable the button if there are validation errors?  I don't want to have to implement all validation twice..once against the elements and again against the button!

    Thanks,

    Craig

  • 05-15-2009 07:14 AM In reply to

    Re: hide/disable button if validation errors?

    Hi,

    Add a boolean secondary field with default value false. For each and every field in the form add an on after change event, and verify whether there are any errors in the form (thisXDocument.Errors.count > 0). If there are errors then set that field value to true. Add a conditional formatting to the button to hide/disable using this field. Also check this condition (thisXDocument.Errors.count > 0) in form onload and set the field value accordingly.

     

    Swathip
    www.ggktech.com
  • 07-14-2009 09:46 AM In reply to

    Re: hide/disable button if validation errors?

    Hi Swathi,

    I tried following this example, but somehow I am not able to set the field a value. Here is the code I am using for the field.

     function msoxd_my_field1::OnAfterChange(eventObj) { 

     if (eventObj.IsUndoRedo)

     { If (thisXDocument.Errors.count = 0)

    XDocument.DOM.selectSingleNode("//my:dummy").text = "TRUE"

    return; }

    And then I created dummy hidden field on the form and I am using conditional formatting on the form to disable it if dummy field is set to FALSE.

    Am I missing something here? Please help.

    Thanks

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.