- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 10:31 AM
Hi All,
I have a requirement where I have to validate a single line text field to have alpha-numeric characters. I have written this onChange script as below, but I think it's not working as expected.
please help me.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.hideFieldMsg('SAP Customer Number');
var patt = "^[a-zA-Z0-9]*$";
if (!patt.test(newValue))
g_form.showFieldMsg('SAP Customer Number','Invalid input','error');
var patt2 = "^[Nn]/[Aa]$";
if (!patt.test(newValue))
g_form.showFieldMsg('SAP Customer Number','Invalid input','error');
}
Thanks in Advance,
SD
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 10:57 AM
I understood the requirement. This time though, I'll repeat the earlier statement and show you the code.
you dont need a regeexp for that. Use .length property of newValue to check.
translates to
var patt = new RegExp("^[a-zA-Z0-9]*$");
if(!patt.test(newValue) || newValue.length != "10"){
// error out.
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 10:57 AM
I understood the requirement. This time though, I'll repeat the earlier statement and show you the code.
you dont need a regeexp for that. Use .length property of newValue to check.
translates to
var patt = new RegExp("^[a-zA-Z0-9]*$");
if(!patt.test(newValue) || newValue.length != "10"){
// error out.
}