I want my input tag to accept only maximum 12 comma separated values.it should not accept values like 1,
mean after comma their is nothing this is the regex I have made.
My current regex is not accepting single value like 1 or a or 12ab
^[0-9a-zA-z]+(,[0-9a-zA-z]+){1,11}$
checked it on http://www.phpliveregex.com/ but it is not working. Here is my whole code
if(!preg_match("/^[0-9a-zA-z]+(,[0-9a-zA-z]+){1,11}$/", $data){
return false
}else{
return $data
}
^[0-9a-zA-Z]+(,[0-9a-zA-Z]+){0,11}$
^^
This should do it for you.See demo.