- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 06:51 PM
Hi all,
We need to validate the text/character entered in a single line text field type to
always start with this special character " \\ "
Can you help me do it using client script? Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 07:08 PM
Hi @ss123
You can implement onChange client script. below is example, I tried this on short description field and it is working fine.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue && !newValue.startsWith("\\")) {
// If it doesn't start with '\', display an error message and clear the field
alert('The value must start with the "\\" character.');
g_form.clearValue('short_description'); // Optional: Clear the value to force re-entry
}
//Type appropriate comment here, and begin script below
}
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 07:08 PM
Hi @ss123
You can implement onChange client script. below is example, I tried this on short description field and it is working fine.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue && !newValue.startsWith("\\")) {
// If it doesn't start with '\', display an error message and clear the field
alert('The value must start with the "\\" character.');
g_form.clearValue('short_description'); // Optional: Clear the value to force re-entry
}
//Type appropriate comment here, and begin script below
}
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 08:49 PM - edited 09-16-2024 08:51 PM
var name= g_form.getValue('name');
if (!name.startsWith('\\')) {
g_form.addErrorMessage('The input of name must start with \\');
or use alert(");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 02:03 AM
@ss123 please accepted as solution and helpful if it resolved