Restriction to filed If not start with specific letters
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 04:34 AM
Hi All,
I have requirement as per the below:
We have one field( Machine Name). For that field restriction as per the below:
Text can only be 9 characters long. Cannot contain special characters or spaces. Must start with 'RTH'. If validation is not followed, an error message pops up ""Machine Name must start with RTH and is 9 characters long"" and the text should be clear .
Please provide the code. How can I achieve this.
Thank you.
1 REPLY 1
Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 05:01 AM
Hi @Sirri ,
Try this - Onsubmit client script
// Regular expression for validation
var regex = /^RTH[a-zA-Z0-9]{6}$/;
// Validate the machine name
if (!regex.match(g_form.getValue("Replace the field"))) {
g_form.addErrorMessage("Machine Name must start with RTH and is 9 characters long");
return false;
}
Ex:
Output 😍:
Hope this helps!!!