프로그래밍 언어/HTML,CSS,JS
HTML5에 minlength 유효성 검사 속성
Rateye
2021. 6. 4. 10:51
728x90
반응형
질문 : HTML5에 minlength 유효성 검사 속성이 있습니까?
<input>
필드의 minlength
속성이 작동하지 않는 것 같습니다.
필드 값의 최소 길이를 설정할 수있는 HTML5에 다른 속성이 있습니까?
답변
pattern
속성을 사용할 수 있습니다. required
속성 도 필요합니다. 그렇지 않으면 빈 값이있는 입력 필드가 제약 조건 유효성 검사 에서 제외됩니다.
<input pattern="." required title="3 characters minimum"> <input pattern="." required title="5 to 10 characters">
"empty, or minimum length"에 대한 패턴을 사용하는 옵션을 만들려면 다음을 수행 할 수 있습니다.
<input pattern=".|." required title="Either 0 OR (5 to 10 chars)"> <input pattern=".|." required title="Either 0 OR (8 chars minimum)">
출처 : https://stackoverflow.com/questions/10281962/is-there-a-minlength-validation-attribute-in-html5
728x90
반응형