how to check if a field contains backslash using client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 03:32 AM
how to check if a field contains backslash using client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 03:35 AM
In Javascript, escape character is backslash. So, you need to use 2 black slashes in this case. Then, you can use indexOf javascript function to check whether value has blackslash or not.
var fieldvalue = g_form.getValue('fieldname');
if(fieldValue.indexOf('\\') >= 0)
alert("Field value has black slash.")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 03:41 AM
It is working
thank you
but can we do it using regex?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 03:48 AM
here it is using regex..
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
Thanks,
Deepa
var pattern=/\\/;
alert(pattern.test(newValue));
if(pattern.test(newValue) )
{
alert('Backslash presnt);
g_form.setValue('u_urfieldname', '');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 03:51 AM
That's great. Check this, if you want to use reg. ex
var fieldvalue = g_form.getValue('fieldname');
var reg=/\b\\/g;
if(fieldvalue.match(reg))
alert("Field value has black slash.")