Reputation: 1343
Is there an easy way to force users to enter numbers only in a Xpages editbox? Other than validating the field after the fact that is. I don't want them to be able to enter a number at all.
Upvotes: 2
Views: 1180
Reputation: 9359
extlib / upgrade pack1 has editors with formatting rules.
Upvotes: 0
Reputation: 50
You write below code in a Xpages editbox on event onkeypress
if (event.keyCode >= 48 && event.keyCode <= 57)
{
event.returnValue = true;
}
else
{
event.returnValue = false;
}
This code will force user to enter numbers only.
Upvotes: 1
Reputation: 700
You can add validation and formatting of numbers using the built in dojo.number class: http://dojotoolkit.org/api/1.6/dojo/number/format and make use of the dojo.form widgets.
If you're running on a mobile web platform (iOS or Android) then you should also think about setting the type of the field to number so that the platform itself will add another level of protection.
Matt
Upvotes: 1
Reputation: 21709
You can add client-side Javascript handling such as what has been suggested here: HTML Text Input allow only Numeric input
Upvotes: 4