daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. I would suggest using regexes:
  2.  
  3. var intRegex = /^d+$/;
  4. var floatRegex = /^((d+(.d *)?)|((d*.)?d+))$/;
  5.  
  6. var str = $('#myTextBox').val();
  7. if(intRegex.test(str) || floatRegex.test(str)) {
  8.    alert('I am a number');
  9.    ...
  10. }
  11.  
  12. Or with a single regex as per @Platinum Azure's suggestion:
  13.  
  14. var numberRegex = /^[+-]?d+(.d+)?([eE][+-]?d+)?$/;
  15. var str = $('#myTextBox').val();
  16. if(numberRegex.test(str)) {
  17.    alert('I am a number');
  18.    ...
  19. }
  20.    
  21. $("#myform").validate({
  22. rules: {
  23. field: {
  24.   required: true,
  25.   number: true
  26.   }
  27.  }
  28. });
  29.    
  30. var ids=$('#Id').val();
  31. if(isNaN(ids))
  32. {
  33. alert("Numbers only");
  34. }
  35.    
  36. $("#myform").validate({
  37.   rules: {
  38.    field: {
  39.     required: true,
  40.     digits: true
  41.    }
  42.  }
  43. });
  44.    
  45. $("#calculator").validate({
  46.   rules: {
  47.     filedName: { // u must replace filedName with ur textbox name (i assume ur textbox name is 'competitor-percent-fee')
  48.       required: true,
  49.       number: true
  50.     }
  51.   }
  52. });
  53.    
  54. $("#calculator").validate({
  55.   rules: {
  56.     field: {
  57.       required: true,
  58.       number: true
  59.     }
  60.   }
  61. });
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