Onchange client scipt how to abort form submission
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 10:38 PM
I have a due date field In my problem form.
I wish to validate the due date on my form and show an field error message ( which I wrote in on change client script) . and my user should not be allowed to submit the form. What would be the peiece of the code that I should write in my onchange client script. Thanks.
- Labels:
-
Problem Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 10:44 PM
Hi Sujan,
Could you please provide the client script which you have written for this?
If I'm not wrong you have used GlideAJAX to validate and showing error message on certain condition and still facing the form submission which is not desirable. If this is the scenario, I would like to suggest you to wait Synchronous GlideAJAX. Please find the link here for more details: Examples of synchronous GlideAjax
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 10:47 PM
Hi Sujan,
I don't know the scenario you are working on, but here's a head start==>
var _now = new Date(); // get system date
var nowDateStr = formatDate(_now, g_user_date_format);
var nowDateNum = getDateFromFormat(nowDateStr, g_user_date_format);
var userDateNum = getDateFromFormat(newValue, g_user_date_format); // This will be your Due Date, no need to change anything
if(nowDateNum < userDateNum){ // Comparing whether Due Date is greater than current date or not
g_form.setValue('date_of_interview','');
g_form.showErrorBox('due_date', 'Invalid Due Date');
return false;
}
Also, make the due_date field mandatory, it will not let the user to Submit the form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 11:05 PM
Hey Sujan,
What is your Validating condition for due_date??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2017 12:05 AM
Thanks for the code part , I have actually achieved that initially in script include , my function also did the same
--> My validating condition
The due date should be at least 24 hours from now .
The due date should not fall on the weekends
Currently I wrote an onsubmit client script to do this , however since the due date is getting changed and I wanted to convert this into onchange client script