Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can check a minimum 3 characters in a given value ,using regular expression

I have javascript code for checking the zipcode

var regexObj =
/^(?=[^-]*-?[^-]*$)[0-9-]*[0-9]$/;

I need to add one more condition to this,ie

make it so that user has to enter a minimum of 3 characters

Can any one say, how can i modify my regular expression for that

like image 202
Linto P D Avatar asked Jan 07 '11 22:01

Linto P D


Video Answer


1 Answers

In HTML5, you can use a pattern.

In your example, you would do the following, where 3 is the minimum value and anything after the comma would be a maximum value (in your case, you don't have a maximum value):

<input pattern=".{3,}">
like image 72
thecoolmacdude Avatar answered Oct 30 '22 11:10

thecoolmacdude