On Sat, 09 Oct 2004 16:29:33 GMT, SAN CAZIANO <al**********@tin.it> wrote:
how can i insert only a real number (an integer with only one decimal
separator) in a edit field
perhaps in onchange event I have to test if the decimal separator in the
text is >0 I simply have to put it as a null key
The best way to check an input format is using a regular expression. Real
numbers can use this basic check:
if(/^(0|[1-9]\d*)\.\d\d$/.test( string )) {
// test succeeded
That expression ensures that a number cannot include leading zeros, and
must have a decimal portion containing two numbers.
0.14 and 12.00
are valid numbers, but
02.50 and 1.0 and .25
are not. If you have specific requirements, such as the inclusion of
integer values, or a range of allowable decimal digits (rather than the
current two), they should be easy to accomodate. Just ask.
Hope that helps,
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.