Invoking validation just after display the form JSF - validation

I have a form where the user should be able to save even if there are validation errors.
These errors should be displayed once the user get into the form again.
So, i would like to invoke the validation of the entire form just after the form is displayed.
Currently, the validation is handled thru AJAX with several custom validators by using <f:validator/> and <p:ajax/> only when the user edits the field
Any suggestion is welcome!
Thanks!

An option would be to submit the form after it loads directly.
To achieve this you can use p:remoteCommand and something like jQuery('document').ready(function(){remoteCommandName()})

Related

Validating form using jquery Ajax MVC

Up to this point, I’ve been using Microsoft Ajax for updates in my MVC app. I’m now switching to jQuery Ajax in order to standardize my approach.
However, I just realized that the required field in my model for the form did not fire and the user was able to submit the form even though some required fields were left blank.
What is the standard way to handle required fields if I’m handling my ajax functions using jQuery – i.e. I want the unobtrusive to handle my required fields by highlighting them and not allow the submit button to be clicked.
Also, to mention I am getting data-val attributes through the model.
P.S. I’m now using an event handler to detect click event on submit button for the form. In other words, I’m not using #using.Ajax.BeginForm to define my form.

Drupal 6 Ajax module: altering form after submission

I am using Ajax module in Drupal 6 to ajaxify my simple contact form. It works fine, the form is ajax-submitted and validation errors are displayed correctly, but I can't figure out a way to alter my form after successful submission. Namely, I want to remove most of my input fields and replace them with a "Thank you for your request" message. I assume this should be somehow achieved with hook_ajax_validate_pass, but I have no idea how to use it... Any help appreciated.

MVC 3 - AutoPostback with CauseValidation=false Behavior

I'm familiar with the method of submitting a form via a change event like or a checkbox's check event. Most articles explain how to find the first form using jQuery and invoke it's submit() method. However, I wish to submit the form but not cause validation so the back-end can perform other actions. In my case, I have a dropdown that a users changes. Depending on the value, the back-end adds/removes certain controls. The issue I'm runing into is that the validation prevents the form from submitting.
Q: How do I submit the form so it does not perform client-side validation?
Remove the validation just before the form is submitted - check out the answers here How do I remove jQuery validation from a form?
I think you can just turn the validation off by calling #Html.EnableClientValidation(false)

struts2/ajax/jQuery dialog behavior

I'm trying to use a jQuery dialog to submit a form via ajax to my struts2 action. On success, I'm redirecting to a different page. This is working great. The issue I'm having is handling non-success result types from my action. What I'd like to happen is for my action/field errors to somehow get populated into my dialog so that the user can make the necessary changes and resubmit the form. Any thoughts would be greatly appreciated.
You should return any errors fromthe action wrapped as a json or formatted HTML whch van then be displayed in the dialog.
JQuery supports error handler method for the Ajax calls make sure you set the http response code properly ans you should be able handle errors differently from success cases.

Appropriate redirection of forms that use AJAX

I have many forms that use AJAX (w/ jQuery) for validation and data submission. When a form is filled out correctly, I use window.location to redirect the page after I get an acceptable response from the PHP script. On the new page, I use a session variable (set after the AJAX calls) to display the appropriate content. Please tell me if this is standard practice or please give me some suggestions.
Thanks!
Is there a reason you would use a $_SESSION variable to store the post-submission content? Standard practice would be to validate the form via AJAX but submit it in the standard way (i.e. via $_GET or $_POST) after validation. This way you don't need to store anything to a session and you'll likely have less to debug as you'll be submitting the form and displaying its results in the most widely-accepted way.
The benefit of AJAX is typically so that you can submit the form without actually having to do the redirect/refresh. You could get the same functionality by simply having your form POST to the destination URL, redirect to the appropriate place from there or send them back to the form displaying any errors that may have occurred. You could use AJAX to validate the form before the submission to save your users a redirection back to the form to fix their errors, but this is really just a convenience for them. Also, you will have to validate any user data on the server side once it has been submitted, as you can't rely on client-side validation, so you might as well forget the AJAX validation.

Resources