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?
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?
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'); } }
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.
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.
Bookmarks