<div class="container-fluid">
<div class="form-check">
<label for="clearIncomplete" class="form-check-label">미완성 입력 지우기:</label>
<input id="clearIncomplete" class="form-check-input" type="checkbox" checked="true">
</div>
<input id="theSSN">
<input id="theZip">
<input id="theZip4">
<input id="thePhone">
</div>
xxxxxxxxxx
.state-invalid {
color: red;
}
label {
width: 180px;
text-align: right;
}
.wj-inputmask {
margin-right: 3px;
}
@font-face {
font-family: 'S-CoreDream-3Light';
src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/S-CoreDream-3Light.woff') format('woff');
font-weight: normal;
font-style: normal;
}
body {
margin: 20px;
font-family: 'S-CoreDream-3Light';
}
.container-fluid{
background-color:#ededed;
padding:10px;
border-radius:10px;
}
xxxxxxxxxx
document.readyState === 'complete' ? init() : window.onload = init;
//
function init() {
let theSSN = new wijmo.input.InputMask('#theSSN', {
mask: '000-00-0000',
placeholder: 'SSN',
isRequired: false,
value: '',
valueChanged: validateMask,
lostFocus: lostFocus
});
//
let theZip = new wijmo.input.InputMask('#theZip', {
mask: '00000',
placeholder: 'Zip Code',
isRequired: false,
value: '',
valueChanged: validateMask,
lostFocus: lostFocus
});
//
let theZip4 = new wijmo.input.InputMask('#theZip4', {
mask: '00000-0000',
placeholder: 'Zip Code + 4',
isRequired: false,
value: '',
valueChanged: validateMask,
lostFocus: lostFocus
});
//
let thePhone = new wijmo.input.InputMask('#thePhone', {
mask: '(999) 000-0000',
placeholder: 'Phone Number',
isRequired: false,
value: '',
valueChanged: validateMask,
lostFocus: lostFocus
});
//
// 'state-invalid' 클래스 업데이트
function validateMask(sender) {
wijmo.toggleClass(sender.hostElement, 'state-invalid', !sender.maskFull);
}
//
// 포커스가 사라질 때 채워지지 않는 마스크 지우기
var clearIncomplete = document.querySelector('#clearIncomplete');
function lostFocus(sender) {
if (!sender.maskFull && !sender.isRequired && clearIncomplete.checked) {
sender.value = '';
}
}
}