Hi:
Due to limitations within our environment, I have to use text fields to enter in numeric data only. The client would need to be prompted upon entering a letter that this field excepts only numeric characters.
I am using the code below on the change event for the field and it works fine except that the client can not enter decimals or commas. Does anyone know how to escape the period and commas with this expression?
if (xfa.event.change.match(/[0-9\-]/) == null)
{
xfa.event.change = "";
xfa.host.messageBox("Only numbers are permitted for this field.");
}
Views
Replies
Total Likes
Hi,
This script in the change event will give the warning. I am just thinking if script could also delete the offending character:
var vPattern = /[a-z]/;
var result = vPattern.test(xfa.event.newText);
if (result == true)
{
xfa.host.messageBox("Only numbers are permitted for this field.");
}
Views
Replies
Total Likes
Thanks!
I never thought about going from the letter side. DOH!
The way to clear the offending character is to add the follow code to your solution
{
xfa.event.change="";
messageBox...
Thanks again,
Views
Replies
Total Likes