- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2019 10:54 PM
Hi Everyone,
I hope you all are doing good. 🙂
Mandatory fields are accepting spaces, without having to enter any character. I need a script for checking single or multiple space too. I took reference from community and tried a code but it is working for a single space. If user will add multiple spaces so this code won't work. The code is given below:
Wrote an onChange Client Script for the field
if (g_form.getValue('u_recommended_ltf') == ' '){
alert("Please fill Analysis Output field ");
g_form.setValue('u_recommended_ltf', '');
}
Could you please help me out for this script.
Kind Regards,
Swati
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2019 11:04 PM
var d = g_form.getValue('u_recommended_ltf');
d = d.replace(/\s/g, "");
if (d==""){
alert("Please fill Analysis Output field ");
g_form.setValue('u_recommended_ltf', '');
}
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 05:55 AM
Thanks Priya! 🙂
Your reply is helpful but the answer i was looking for is already given by Ahmmed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2019 11:04 PM
var d = g_form.getValue('u_recommended_ltf');
d = d.replace(/\s/g, "");
if (d==""){
alert("Please fill Analysis Output field ");
g_form.setValue('u_recommended_ltf', '');
}
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 05:49 AM
Thanks Ahmmed!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2019 11:18 PM
You can use REGEX. So next time you have flexibility to add more validation when needed.
Below is example to check white space & blank. You can refer to this for REGEX https://www.regextester.com/98264
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var regex = new RegExp("^(?!\s*$).");
if(!regex.test(newValue)){
alert('No content');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 05:58 AM
Thanks Weikiat.G!
I got the solution already