How to validate given number is integer or float using JavaScript.

Posted by Allemahesh under JavaScript on 7/16/2013 | Points: 10 | Views : 1891 | Status : [Member] [MVP] | Replies : 3
How to validate given value is integer or float using JavaScript.




Responses

Posted by: Rimi1289 on: 7/16/2013 [Member] Starter | Points: 25

Up
0
Down
You can use JQuery to do the client side validation.
Like this...
http://www.encodedna.com/2013/05/enter-only-numbers-using-jquery.htm


Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 7/16/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Dear Rimi, I have seen the above link. Here they are validating on key press event. But I want to validate on submit button click event. Any help.

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ssj_Kumar on: 7/17/2013 [Member] Starter | Points: 25

Up
0
Down
function getType(inputValue) {
var data= (/[\d]+(\.[\d]+)?/).exec(inputValue);
if (data) {
if (data[1]) { return 'float'; }
else { return 'int'; }
}
return 'string';
}



Regards,
Jayakumar Selvakani

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response