- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2017 12:32 AM
Hello All,
I have a requirement like, single line textbox allow alphanumerics only, it restricts for only 4 digits combination alphanumeric, if user enters more than 4 digits it will show field error message like "it accepts only 4 digits or character"
I have written below script it does not as I expected
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var subject = g_form.getValue('name'_var);
var regexp = /^[a-zA-Z0-9.]*$/; // accept 0 to 9 numbers only
if(!regexp.test(newValue) || subject>9999 || subject>zzzz )
{
g_form.showFieldMsg('name_var','Please enter only 4 digits','error');
g_form.setValue('name_var','');
}
//Type appropriate comment here, and begin script below
}
Can any one help on this requirement
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2017 02:50 AM
Hi Burra,
Create one onchange client script and use this below code for this requirement:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var letterNumber = /^[0-9a-zA-Z]+$/;
if(!(newValue.match(letterNumber)) || newValue.toString().length>4)
alert('It accepts only 4 digits or character');
}
//Type appropriate comment here, and begin script below
Regards,
Souren
Hit correct/helpful based on impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2017 02:50 AM
Hi Burra,
Create one onchange client script and use this below code for this requirement:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var letterNumber = /^[0-9a-zA-Z]+$/;
if(!(newValue.match(letterNumber)) || newValue.toString().length>4)
alert('It accepts only 4 digits or character');
}
//Type appropriate comment here, and begin script below
Regards,
Souren
Hit correct/helpful based on impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2017 02:59 AM
g_form.showFieldMsg('short_description',"It accepts only 4 digits or character.",'error'); can be replaced with the alert statement.