How to use pattern Attribute in HTML5, means what to do if i want to allow only "a-g" letters & want to restrict "h,i,j,k...z". | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to use pattern Attribute in HTML5, means what to do if i want to allow only "a-g" letters & want to restrict "h,i,j,k...z".

26th Feb 2017, 5:59 AM
Arunbir Singh
Arunbir Singh - avatar
4 Answers
+ 18
text.match(/[a-g]*?/gmi)
26th Feb 2017, 7:51 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 10
this is used to limit the user input
26th Feb 2017, 11:28 AM
Siddharth Saraf
+ 4
As already suggested, pattern attribute expect a regular expression as filter, so you need to study them ( this is another language, used/implemented in almost programming languages, usefull for string treatments )... You can find a lot pages about it, regardings differents languages implementations, with google... Mainly, syntax is always same, differing just on some details ( not all advanced features always implemented in example ). In the case of Html, the syntax is the one of JS. I can recommend a good link, but in french: http://www.expreg.com/memo.php Else, in english, maybe this one: http://www.regular-expressions.info
26th Feb 2017, 11:18 AM
visph
visph - avatar
+ 1
read regular expression
26th Feb 2017, 7:26 AM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar