Bruce Stemplewski
Bruce Stemplewski

Reputation: 1343

Numbers only in Xpages editbox?

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

Answers (4)

Simon O'Doherty
Simon O'Doherty

Reputation: 9359

extlib / upgrade pack1 has editors with formatting rules.

Upvotes: 0

YOGI
YOGI

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

Matt White
Matt White

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

Per Henrik Lausten
Per Henrik Lausten

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

Related Questions