HTML DOM 입력 이메일 maxLength 속성은 입력 이메일에 대한 maxLength 속성을 반환/설정합니다. 정의되지 않은 경우 이 속성은 '-1'을 반환합니다.
구문
다음은 구문입니다 -
- maxLength 반환 속성
inputEmailObject.maxLength
- maxLength 설정 속성을 숫자로
inputEmailObject.maxLength = number
예시
입력 이메일 maxLength의 예를 살펴보겠습니다. 속성 -
<!DOCTYPE html>
<html>
<head>
<title>Input Email maxLength</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form id="Multitech-MNC">
<fieldset>
<legend>Email-maxLength</legend>
<label for="EmailSelect">Employee Email :
<input type="email" id="EmailSelect" placeholder="jkl@qwerty.com" maxLength="10">
</label>
<input type="button" onclick="logIN()" value="Log In">
<input type="button" onclick="changeMaxLength()" value="Change Maxlength">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputEmail = document.getElementById("EmailSelect");
divDisplay.textContent = 'Maxlength: '+inputEmail.maxLength;
function changeMaxLength() {
inputEmail.maxLength += 5;
divDisplay.textContent = 'Maxlength: '+inputEmail.maxLength;
}
function logIN(){
if(inputEmail.value !== '')
divDisplay.textContent = 'Logging Into: '+inputEmail.form.id;
else
divDisplay.textContent = 'Please enter valid email';
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -
'최대 길이 변경'을 클릭하기 전에 버튼 -

'최대 길이 변경'을 클릭한 후 버튼 -

'로그인'을 클릭한 후 버튼 및 이메일 입력 설정 -
