Javascript isNumber / isNumeric function
| Script version: | 1.1 |
| Language: | Javascript |
| Rating: |
5.9 (10 votes cast) |
| Category: | Form validation |
| Description: | This function checks whether an inputted value is a number or not. There are 3 parameters: the first is the string to check, - accepts a string value - this parameter is mandatory the second optional parameter tells the function whether to include non whole numbers, accepts either true or false (true means that decimal points are accepted the third optional parameter tells the function whether to include negative numbers, accepts true or false (true means that negative numbers are valid [note, this script was updated on 16/11/09 to correct the case error in the last line of code. |
| Instructions: | Example call to the function as follows: alert(isNumeric('12345')) // - returns true alert(isNumeric('-12345')) // returns false alert(isNumeric('-12345',true,true)) // returns true alert(isNumeric('12E45')) // returns false alert(isNumeric('0.12345',false)) // returns false alert(isNumeric('0.12345',true)) // returns true |
| Code: | |
Comments
Related Scripts:
Javascript email validation - simple versionJavascript check valid phone number
Javascript check for valid URL syntax
Javascript improved email validation script
Tags
[ isnumber ] [ numeric ] [ parseint ] [View tag cloud]Back to main scripts page
Tag Cloud Submit a script
Latest Scripts Added
jQuery image swap on mouseover (jQuery)04 January 2012
This simple bit of code allows you to quickly create image rollovers. The code was modified from a version by Sam Colletts on http://webdevel.blogspot.com/2008/04/rollover-images-with-jquery.html ...
replace XML characters in a string using ASP.Net (ASP.Net)
12 December 2011
Sometimes you need to insert a string into an xml document. Before doing this, you need to ensure that your string does not contain any special xml characters. It is possible to use a CDATA section ...
How to remove title tag in ASP.Net (ASP.Net)
14 October 2011
This is not really a script, but a little trick that you can use to remove the title tag in ASP.net. In ASP.net, when the head tag is rendered, the title tag is automatically added. One of the real ...
ASP sort numerical array (ASP)
12 September 2011
This code is similar to the sort array script which sorts an array alphabetical, however it also sorts arrays based on numberical ordering, for example: dim numbers(4) numbers(0) = ...
Force file download in ASP.Net / c# (ASP.Net)
02 September 2011
this script allows you to force browsers to display a file save dialogue for any file type. It contains a string of allowed file types so users cannot change the querystring to downoad your ...

