- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 06:24 PM
Extract characters and check if the extracted value is a number.
If there is the following value, I want to extract the first 3 characters and determine whether the value is a number.
123-456
If there is no number, print an error message in the field.
Other conditions
Use Client Script
Check with onSubmit
Please let me know if you know.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 07:40 PM
@user_ms Here is the script
function onSubmit() {
//Type appropriate comment here, and begin script below
var textBox= g_form.getValue('text_box');
var pattern = /^\d{3}-/;
if(pattern.test(textBox)){
g_form.showFieldMsg('text_box','correct');
}
else{
g_form.showFieldMsg('text_box','incorrect');
}
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 08:23 PM
hi
function onSubmit() {
var fieldValue = g_form.getValue('your_field');
var firstThreeChars = fieldValue.substring(0, 3);
if (!isNaN(firstThreeChars)) {
} else {
g_form.addErrorMessage("The first three characters must be a number.");
return false;
}