1 Reply Latest reply on May 14, 2013 2:52 AM by Muppet Mark

    Regex - Limit input to a positive number (float or int)

    Petfactory Level 1



      I wish to limit the user input of and edittext to only allow a positive number, float or int. I do not yet know my Regex good enough to do this. I realize that I must get better at regex but in the meantime does any one know how to do this ?


      I have used this so far on the edittext:


      function checkTextInput() 
          if (this.text.match(/[^0-9.]/g)) 
              this.text = this.text.replace(/[^0-9.]/g, ""); 


      Which matches



      which is not desired.


      Desired is





      Best Regards,