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
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.
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?
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.
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
}
});
This solution is good and simple. This is similar to trigger validations except it validates before the form is submitted.
You can also add JavaScript code to "onsubmit" event handled on Page's Properties page.