By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,137 Members | 2,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,137 IT Pros & Developers. It's quick & easy.

javascript for a textbox to accept the values in decimals and within range

P: 23
Hi,
Plz provide me javascript :

javascript for a textbox to accept the values in decimals and within range

i need to enter a value in textbox like 1.03 and it should be <3 (lessthan 3).

Plz help me.

Rgds,
Nussu
Nov 16 '07 #1
Share this Question
Share on Google+
7 Replies


Dasty
Expert 100+
P: 101
Expand|Select|Wrap|Line Numbers
  1. function check(value)
  2. {
  3.   if (/^[0-9]*(\.[0-9]{1,2})?$/.test(value))
  4.   {
  5.     if (parseFloat(value) < 3.0)
  6.     {
  7.       return true;
  8.     }
  9.   }
  10.   return false;
  11. }
It will check for none up to 2 decimal places. If you want to accept more, just change "2" in regular expression to higher number. This function returns true if value is ok, otherwise false.
Nov 16 '07 #2

P: 23
Thnx Dasty,

It is working fine now.
Nov 16 '07 #3

P: 23
Hi,

A textbox has to accept only numeric values using javascript in .net 2.0

Once i comeout of textbox and if it is not numeric value i have to get alert.

Plz provide me complete code ..

code in textbox and as well as javascript function.

I am new to .net plz help me...

Plz help me ...

Regards,
Nussu
Nov 18 '07 #4

gits
Expert Mod 5K+
P: 5,371
hi ...

you might have a look at this thread ...

kind regards
Nov 18 '07 #5

Markus
Expert 5K+
P: 6,050
Hi,

A textbox has to accept only numeric values using javascript in .net 2.0

Once i comeout of textbox and if it is not numeric value i have to get alert.

Plz provide me complete code ..

code in textbox and as well as javascript function.

I am new to .net plz help me...

Plz help me ...

Regards,
Nussu
Don't be so cheeky and read a tutorial.
Nov 18 '07 #6

P: 23
Hi,

I need a javascript for a textbox to accpet only decimal values( i.e as 0.005) and
if it is < 0.005 i need to raise an alert.

Help me plz

Regards,
Nussu
Nov 26 '07 #7

acoder
Expert Mod 15k+
P: 16,027
I've merged your threads yet again. Keep all posts on one topic in one thread. This is your final warning.
Nov 26 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.