Page level UI validation before submitting the page

Posted by ithrees on 25-Mar-2015 03:07

Hi All,

How we can do the UI level validation combining multiple fields (other than field validation) when click on the 'Submit' button. In case of violation we should remain in the page without submitting the form.

Thanks in advance,
Ithrees

All Replies

Posted by Godfrey Sorita on 25-Mar-2015 07:47
Both Field and Trigger validations are done server-side to ensure these rules are checked before saving the data. If you want to fire validations client-side, then you would need to manually re-code all validation rules to a script component.
Posted by ithrees on 25-Mar-2015 10:27

What if I want to run the validation when click on the 'Submit' button of the create/edit page. It should override the default page submission and to wait until validation is over and then to proceed. Is there any api available for this?

Posted by Godfrey Sorita on 25-Mar-2015 11:12
I believe what you are looking for is a functionality to disable the submit button until the required fields are filled and validations are met. Unfortunately there is no API for this.
Posted by ithrees on 26-Mar-2015 00:14

I tried something like this script below and it worked for me. Still expecting better ideas..

$("form").submit(function(event){  

 var errFlag = false;

 /* my validation

   set the errFlag if there is a violation

 */

 //check errFlag

 if (errFlag){

   event.preventDefault(); // prevent from submitting

   //display error message..

   $('input[type="submit"]').prop("disabled",false); // enable the submit button

 }

});

Posted by Godfrey Sorita on 26-Mar-2015 10:57
This solution is good and simple. This is similar to trigger validations except it validates before the form is submitted.
Posted by pvorobie on 26-Mar-2015 11:27

You can also add JavaScript code to "onsubmit" event handled on Page's Properties page.

This thread is closed