How to restrict the form to be submitted when the script condition matches and to retain oldValue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi All,
I am passing a validation when the below script condition matches through onchange Client script. But at the same time I need to restrict user from submitting the form with if the value of the justification field is less than 60.Also if user does any changes to a existing value and try to submit a newValue of less than 60 character, it should not take and the justification field should should retain it's oldValue . I have tried below scripts, onChange is working as expected but not sure how to restrict user from submitting the form with incorrect value without impacting existing value of the field(If form is getting submitted with value length <60).
Please suggest me on this what should be best approach to achieve this ? Please let know if you nee more info .
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi@Ankur Bawiskar ,
I am just wondering what should be the best approach for this I found there is already a existing client callable script Include which is used to make that field mandatory through on load client . Should I use this script include calling it in my OnSubmit client script checking if the value length is less than 60 then it will not allow to submit and if more than equal to 60 then it would allow to submit the form . If this approach is correct then could please help me with script , I am not sure where the function needs to be declared , I mean in script include or in client script ? I have attached the script Include below.
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
when you can do something directly with client script why would you use GlideAjax + Script Include?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
We don't want to create new BR and trying to incorporate with existing developments so that is the cause behind it . I was trying the below script include and client script , could you please suggest if this is good to follow or require any changes ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
please share your actual business requirement.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Requirement is when justification field changes and it's length is less than 60 character then it should show a validation message and shouldn't allow the form to submit . But in this process I am facing difficulties like if i can incorporate my development with existing development or not where justification field is already getting mandatory with above mentioned script Include and a Onload client script.
