Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 10-08-2009
Member
 
Join Date: Feb 2009
Posts: 71
How to check if value is numeric javascript

How do I validate a number and check to see if its a number(say between 0 and 10) and not a string or alphabet, i just need to check if input entries are positive numbers, javascript have a built in function for this?
Reply With Quote
  #2  
Old 10-08-2009
Member
 
Join Date: Mar 2008
Posts: 232
Re: How to check if value is numeric javascript

Numeric validation becomes important if multiple numeric fields are required on a page, especially if their values are to be summed or used in some mathematical function.

then to check if the number is positive:
Code:
function checkPos()
{
if(parseInt(document.getElementById('ID').value) > 0)
{
alert('the number is positive');
}
else
{
alert('The number is not positive');
}
}
Reply With Quote
  #3  
Old 10-08-2009
Member
 
Join Date: Jan 2009
Posts: 140
Re: How to check if value is numeric javascript

The simplest way to check whether the details entered in a text field are numeric is to to loop through the string all the element's values in javascript are strings, not numbers, so that you better transform them into numbers before any math operation. and compare each character to a pre-defined list of acceptable characters. I have a good programming job, and i just bought a new Car! thanks again.
Reply With Quote
  #4  
Old 10-08-2009
Member
 
Join Date: Oct 2008
Posts: 68
Re: How to check if value is numeric javascript

Using the charAt method, we can find out which character is filling a designated position within a string. We then use the indexOf method to search our ValidChars list of valid characters. I just want it to pick up the value of the size whether it is a text or numeric value and transfer the size and corresponding information for that size to the shopping cart.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to check if value is numeric javascript"
Thread Thread Starter Forum Replies Last Post
How to check all the checkboxes by using JavaScript? Dhano Software Development 6 12-04-2012 02:49 AM
Can Not Use Numeric Keypad On P505D Seema Bhati Portable Devices 5 15-01-2011 06:43 PM
Touchscreen with numeric keyboard. Triple-X Portable Devices 3 12-10-2009 03:14 PM
Error: "Arithmetic overflow error converting numeric to data type numeric." Nthing Software Development 3 11-06-2009 10:23 AM
Numeric TextBox in VB.NET Gauresh Software Development 0 22-12-2008 05:18 PM


All times are GMT +5.5. The time now is 11:55 AM.