php - Check input type value for validation -
i need check input type value must start (wv), , must have 17 additional characters.
for example:
if user write 1223ggg
, must show me message:
your entry invalid must wvxxxxxxxxxxxxxxxxx
if user write wv12365478996325874
, must show me message:
your entry success
how can that?
casimir's solution might not have worked because want string 19 characters, not 17.
an updated version of be:
if (strpos($str, 'wv')===0 && strlen($str)==19) {
my regex solution be
if(preg_match('/^wv.{17}$/', 'wv12365478996325874')) { echo 'your entry success'; } else { echo 'your entry invalid must wvxxxxxxxxxxxxxxxxx'; }
if want characters numbers after wv
replace .
\d
.
php demo: https://eval.in/513858
regex101 demo: https://regex101.com/r/mu1kw8/1
depending on need might able use ctype
, http://php.net/manual/en/book.ctype.php, validate string.
Comments
Post a Comment