0

Dear Experts

I want textbox1 to accept only numeric data as 55,65,698.00

Is there any easy way to validate textbox1 with javascript?

Please help

4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by JamesCherrill
0

this is a Java forum, not a JavaScript forum (no, they are not the same)
and to answer your question: yes, there is, and even if I'm mistaken and it's not a standard validation, it's not that hard to write.

0

Use some regex pattern to check the contents of the textbox: if it matches [^0-9,], you have a non-numerical input.

1

Assuminbg this is a Java question, not JavaScript, use a JFormattedTextField

Formatted text fields provide a way for developers to specify the valid set of characters that can be typed in a text field. Specifically, the JFormattedTextField class adds a formatter and an object value to the features inherited from the JTextField class. The formatter translates the field's value into the text it displays, and the text into the field's value.

Using the formatters that Swing provides, you can set up formatted text fields to type dates and numbers in localized formats. Another kind of formatter enables you to use a character mask to specify the set of characters that can be typed at each position in the field. For example, you can specify a mask for typing phone numbers in a particular format, such as (XX) X-XX-XX-XX-XX.

http://docs.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.