Previous | Next | (P-PDF) JavaScript
Topic: Not allow hyphen in character 30, 60, 90, 120
Conf: (P-PDF) JavaScript, Msg: 66162
From: Jub
Date: 6/4/2002 11:57 AM
Cindy,
I think you are getting unexpected results because you are using event.change
Something like the following might work for you...
var reHyphen = /-/;
if(event.willCommit)
{
if(reHyphen.test(event.value))
{
for (var i = 0; i < event.value.length; i++)
{
if( ( i==29 || i==59 || i==89 || i==129 ) && reHyphen.test( event.value.charAt(i) ) )
{
app.a lert("no hyphens in the 30th, 60th, 90th or 120th position");
event.value = "";
}
}
}
}
This will only check when the user tries to commit the value.
If you need to capture the hyphen at the moment it is entered you may need to merge the event.change with the existing event.value and then test the resulting string.
Check out the canned function - AFMergeChange() in your AForm.js, which might be useful.
HTH,
Jub