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

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -