if statement - Integer only if-else condition in php -


I can not be an integer only for the contact number

  if ($ contactno = "") {$ Error ['contact'] = "contact is required."; } Else {if (! Preg_match ("/ ^ ([1] -)? [0- 9] {3} - [0- 9] {3} - [0- 9] {4} $ / i", $ Contactno)) $ valid_Contactno = $ contacts; } And {$ error ['contactno'] = "number only."; }    

Instead, use it to check the numbers.

  if (ctype_digit ($ contactno)) echo "This is a valid contact number!"; } Else {echo "You can not enter characters other than numbers"; }    

Comments

Popular posts from this blog

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -