You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by codix <ja...@yahoo.com> on 2012/01/05 09:16:45 UTC

Numeric Filter on TextField

I have a TextField for filtering the data in a DataTable. However, the rows
in the table is purely numeric. How do I prevent users from entering
non-numeric input on the TextField by using an onKeyUp event?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Numeric-Filter-on-TextField-tp4264649p4264649.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Numeric Filter on TextField

Posted by "Rain... Is wet!" <or...@hotmail.de>.
Maybe this is more helpful to You than my previous post:
http://www.mkyong.com/wicket/how-to-dynamic-add-attribute-to-a-html-tag-in-wicket/


-----
Never forget your umbrella ! In case You did, try to find a shelter ;)
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Numeric-Filter-on-TextField-tp4264649p4268663.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Numeric Filter on TextField

Posted by codix <ja...@yahoo.com>.
Thank you for the reply. I was thinking of integrating it not on the HTML
markup but on the class itself.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Numeric-Filter-on-TextField-tp4264649p4268648.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Numeric Filter on TextField

Posted by "Rain... Is wet!" <or...@hotmail.de>.
In the markup, add the attribute "onkeypress="YOURFUNCTION(event)" to your
textfield.

In your function get the keycode from the event and then use if/else or
switch/case to return true on every keycode from 47 to 57 (ASCII-codes for 0
to 9) or to return false for any other keycode.
Get yourself an ASCII-table to find other keycodes that might be worth to be
lettin through (ENTER on IE8, or ctrl on FF and others).

-----
Never forget your umbrella ! In case You did, try to find a shelter ;)
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Numeric-Filter-on-TextField-tp4264649p4265030.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Numeric Filter on TextField

Posted by François Meillet <fm...@meillet.com>.
Have a look to 
http://stackoverflow.com/questions/469357/html-text-input-allow-only-numeric-input

François


Le 5 janv. 2012 à 09:16, codix a écrit :

> I have a TextField for filtering the data in a DataTable. However, the rows
> in the table is purely numeric. How do I prevent users from entering
> non-numeric input on the TextField by using an onKeyUp event?
> 
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Numeric-Filter-on-TextField-tp4264649p4264649.html
> Sent from the Users forum mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org