0

I tried webform validation, I can validate textfield component for numeric value. However, I cannot find how to set it as integer value only. How can I validate numeric (integer) value.

  • By "how to set it as integer value", do you mean you're looking to store the internal PHP webform data as an int instead of a string? – Shawn Conn May 10 '15 at 18:14
  • To limit user submission in the textfield component as integer value only. When I use webform validation (for example "1|100") the submission 1.5 can be accepted. – Waluyo Adi Siswanto May 10 '15 at 22:25
2

Webform Validation's numeric validator relies on PHP's is_numeric. Thus, any numeric expression (e.g. 1.5) is going to be validated there. In order to validate integers only, you'll need to use Regex validation where only integers character can be valid (e.g. "^([0-9]+)$").

  • Thank you, that's perfect, this what I want. I did not realize there is regular expression and I did not know the code. Now I can set to accept only 1 to 1000 and integer only in the textfield component. The webform validation to the field: Numeric values "1|1000" and Regular expression "^([0-9]+)$" – Waluyo Adi Siswanto May 11 '15 at 1:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.