how let insert real number

S

SAN CAZIANO

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
 
G

George Hester

SAN CAZIANO said:
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

Hi SAN.

I'm not sure if I understand the beginning of your post. An Iinteger NEVER has a decimal in it. In other words
6.0 is NOT an Integer. It is Real yes but not an Integer. Seperators are usually used in how an array is contructed For example var arr = 3,5,7,8 are comma seperated Integers; the array is arr. If you want to use . as a seperator then 3.5.7.8 are decimal seperated Integers. I don't think you can have decimal seperated Real numbers.

As for your javascript ? the experts can probably give you what you want. But this amatuer doesn't understand your intro.
 
M

Michael Winter

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top