Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add record form validation errors not cleared #27

Closed
GoogleCodeExporter opened this issue May 24, 2015 · 6 comments
Closed

Add record form validation errors not cleared #27

GoogleCodeExporter opened this issue May 24, 2015 · 6 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Click the add button to open the add form.
2. Leave a required field or fields blank.
3. Click the OK/Submit button to trigger the validation errors.
4. Click the cancel or close button to close the form.
5. Click the add button to re-open the form. The existing errors remain, 
instead of being cleared.

What version of the product are you using? 
1.2.5


Original issue reported on code.google.com by dmol...@gmail.com on 7 Jun 2011 at 6:22

@GoogleCodeExporter
Copy link
Author

I fixed this by modifying the _fnOnCancelRowAdding(event) function to the 
following:

        //Called when user cancels adding new record in the popup dialog
function _fnOnCancelRowAdding(event) {
    //Close the dialog
    oAddNewRowForm.dialog('close');
    $(oAddNewRowForm).validate().resetForm();      <---- This is the line I added
    $(oAddNewRowForm)[0].reset();
    $(".error", $(oAddNewRowForm)).html("");
    event.stopPropagation();
    event.preventDefault();
}

Original comment by dmol...@gmail.com on 7 Jun 2011 at 7:14

@GoogleCodeExporter
Copy link
Author

Also, if the user has the error messages displayed in a div with class "error", 
it won't be cleared properly if the form is closed after a validation error. 
The changes below fix that:

//Called when user cancels adding new record in the popup dialog
function _fnOnCancelRowAdding(event) {
//Close the dialog
   oAddNewRowForm.dialog('close');
   $(oAddNewRowForm).validate().resetForm();  // Clears the validation errors
   $(oAddNewRowForm)[0].reset();
   $("div.error span", $(oAddNewRowForm)).html("");
   $("div.error", $(oAddNewRowForm)).hide();  // Hides the error div
   event.stopPropagation();
   event.preventDefault();
}

Original comment by dmol...@gmail.com on 8 Jun 2011 at 11:20

@GoogleCodeExporter
Copy link
Author

Hi,

I have not noticed this issue. I all my examples on the site, when error is 
shown following code clear the form and error labels:
    $(oAddNewRowForm)[0].reset();
    $(".error", $(oAddNewRowForm)).html("");
Only potential issue is that when user closes the form (e.g. click on the [x] 
button in the upper right corner), form/messages are not cleared (to enable 
user to continue with editing if he accidentelly closed the dialog).

However I have added your code because it does nto collide with the current 
code. The only change is that I have not included div in the selector because  
would not link to put any constraint such as "you must wrap error labels in the 
div tags".
Current code is:

        //Called when user cancels adding new record in the popup dialog
        function _fnOnCancelRowAdding(event) {
            //Clear the validation messages and reset form
            $(oAddNewRowForm).validate().resetForm();  // Clears the validation errors
            $(oAddNewRowForm)[0].reset();

            $(".error", $(oAddNewRowForm)).html("");
            $(".error", $(oAddNewRowForm)).hide();  // Hides the error element

            //Close the dialog
            oAddNewRowForm.dialog('close');
            event.stopPropagation();
            event.preventDefault();
        }

Could you please take the latest version and let me know whether it wrks in 
your example?

Thanks,
Jovan


Original comment by joc...@gmail.com on 11 Jun 2011 at 8:33

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

This works. I have to include the div/span due to implementation details of my 
application.

Original comment by dmol...@gmail.com on 11 Jun 2011 at 11:06

@GoogleCodeExporter
Copy link
Author

Ok,I'm closing this issue.

Original comment by joc...@gmail.com on 11 Jun 2011 at 3:24

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Just a note regarding this error: $(oAddNewRowForm)[0].reset is not a function

If you happen to have a form reset button with id="reset", this will cause this 
issue to occurr also.

Just a note to assist others.

Original comment by obj...@gmail.com on 13 Oct 2011 at 7:12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant