daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest May 16th, 2018 99 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. var intRegex = /^d+$/;
  2. var floatRegex = /^((d+(.d *)?)|((d*.)?d+))$/;
  3.  
  4. var str = $('#myTextBox').val();
  5. if(intRegex.test(str) || floatRegex.test(str)) {
  6.    alert('I am a number');
  7.    ...
  8. }
  9.    
  10. var numberRegex = /^[+-]?d+(.d+)?([eE][+-]?d+)?$/;
  11. var str = $('#myTextBox').val();
  12. if(numberRegex.test(str)) {
  13.    alert('I am a number');
  14.    ...
  15. }
  16.    
  17. isNaN(123)           // false
  18. isNaN(-1.23)         // false
  19. isNaN(5-2)           // false
  20. isNaN(0)             // false
  21. isNaN("100")         // false
  22. isNaN("Hello")       // true
  23. isNaN("2005/12/12")  // true
  24.    
  25. if (isNaN( $("#whatever").val() )) {
  26.     // It isn't a number
  27. } else {
  28.     // It is a number
  29. }
  30.    
  31. /^d+$/.match(value)
  32. Number(value) == value
  33.    
  34. $("form").validate({
  35.             errorElement: "div",
  36.             errorClass: "error-highlight",
  37.             onblur: true,
  38.             onsubmit: true,
  39.             focusInvalid: true,
  40.             rules:{
  41.                 'nrInput': {
  42.                     number: true,
  43.                     required: true
  44.                 }
  45.             });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top