티스토리 뷰

HTML5 <Input>태그 pattern 정규 표현식 모음


1. 숫자만(공백x)

<input type="text" name="patternValue" pattern="^[0-9]+$">

 

2. 대소문자

<input type="text" name="patternValue" pattern="^[a-zA-Z]+$">

 

3. 소문자

<input type="text" name="patternValue" pattern="^[a-z]+$">

 

4. 대소문자 or 숫자

<input type="text" name="patternValue" pattern="^[a-zA-Z0-9]+$">

 

5. 소문자 or 숫자 

<input type="text" name="patternValue" pattern="^[a-z0-9]+$">

 

6. 소문자 && 숫자 && 8~16자리 숫자 (아이디 유효성검사)

<input type="text" name="patternValue" pattern="^(?=.*[a-z])(?=.*\d)[A-Za-z\d]{8,16}$">

 

7. 소문자 && 숫자 && 특수문자 && 8~16자리 숫자 (패스워드 유효성검사)

<input type="text" name="patternValue" pattern="^(?=.*[a-z])(?=.*\d)(?=.*[$@$!%*#?&])[a-z\d$@$!%*#?&]{8,16}$">

 

8. 대소문자 && 숫자 && 특수문자 && 8~16자리 숫자 (패스워드 유효성검사)

<input type="text" name="patternValue" pattern="^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,16}$">

 

728x90

'HTML' 카테고리의 다른 글

[HTML] 구글 웹폰트 적용하기 - preconnect, preload 속성  (0) 2023.01.05
HTML : 폼(Form)에 대한 이해  (0) 2022.10.27
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/07   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함