Need client script for user should enter value up to 50characters long. No special characters(@,#)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2023 10:50 AM
Require client script for user should enter the value up to 50 characters long.No special characters(@,#,*), if not following alert appears:
"You entered special character-please renter"
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2023 11:09 AM
Hi,
You can use below regex-
var regex = /^[^@#*]{1,50}$/;
var input = "YourStrin@gHere"; // Replace with your input string
if (regex.test(input)) {
gs.log("Valid string");
} else {
gs.log("Invalid string");
}
Thanks and Regards,
Saurabh Gupta
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2023 11:41 AM - edited ‎09-13-2023 11:45 AM
Hi @User_267
Use this script in onSubmit CS
function onSubmit() {
var field = g_form.getValue('field_name'); // Replace 'field_name' with the actual field name
// Define a regular expression to match special characters
var specialCharsRegex = /[@#*]/;
if (specialCharsRegex.test(field)) {
alert('Special characters (@, #, *) are not allowed. Please reenter.');
return false;
}
// Check if the field value is longer than 50 characters
if (field.length > 50) {
alert('Value should be up to 50 characters long. Please reenter.');
return false;
}
return true;
}
If you find this useful Please Mark my answer as Helpful and Accepted solution
Thank you
Praneeth S