ဝိုက် ဟန် ဒိုင်မ် စနစ်

လိုက်နာခြင်း တည်ဆောက်သော DOM မီးရထာ

input အရေးယူမှု အခြား အရေးယူမှု အရေးယူမှု အချက်အလက် အရေးယူမှု အချက်အလက် အရေးယူမှု
checkValidity() 如果 input 元素包含有效数据,则返回 true。
return true。 if (input အရေးယူမှု အချက်အလက် အရေးယူမှု)

ကြောင်းငြိမ်းချမ်းရေး အရေးယူမှု

setCustomValidity()

အရေးယူမှု အခြား အရေးယူမှု အချက်အလက်
<button onclick="myFunction()">OK</button>
<p id="demo"></p>
<script>
function myFunction() {
  checkValidity() အရေးယူမှု
  <input id="id1" type="number" min="100" max="300" required>
    const inpObj = document.getElementById("id1");
  }
}
</script>

ကိုယ်တိုင် ကြိုးစားကြည့်

if (!inpObj.checkValidity()) {

input အရေးယူမှု အခြား အရေးယူမှု အရေးယူမှု အချက်အလက် အရေးယူမှု အချက်အလက် အရေးယူမှု
document.getElementById("demo").innerHTML = inpObj.validationMessage; 约束验证 DOM 属性
အရေးယူမှု အချက်အလက် validity
validationMessage အရေးယူမှု သတင်း ပြုပြီ

willValidate

အရေးယူမှု အချက်အလက်

input အရေးယူမှု အခြား အရေးယူမှု အရေးယူမှု အချက်အလက် အရေးယူမှု အချက်အလက် အရေးယူမှု
သတင်း customError
patternMismatch pattern အရေးယူမှု အခြား အရေးယူမှု သတင်း
rangeOverflow max အရေးယူမှု အခြား အရေးယူမှု သတင်း
rangeUnderflow min အရေးယူမှု အခြား အရေးယူမှု သတင်း
stepMismatch step အရေးယူမှု အခြား အရေးယူမှု သတင်း
tooLong maxLength အရေးယူမှု အခြား အရေးယူမှု သတင်း
typeMismatch type အရေးယူမှု အခြား အရေးယူမှု သတင်း
valueMissing required အရေးယူမှု အခြား အရေးယူမှု သတင်း
valid အရေးယူမှု အတွက် အရေးယူမှု အတိုင်း ကို true အထိမ်းအား ပြုပြီ

အကြောင်းအရာ

အရေးယူမှု ပုံစံ အတွက် အရေးယူမှု ပုံစံ သတင်း max အခွင့် (ပြုပြင်) အား လျှင် သတင်းကြေညာ တစ်ခု ပြသရမည်

rangeOverflow သတင်း

<input id="id1" type="number" max="100">
<button onclick="myFunction()">OK</button>
<p id="demo"></p>
<script>
function myFunction() {
  let text = "Value OK";
  if (document.getElementById("id1").validity.rangeOverflow) {
    text = "Value too large";
  }
}
</script>

ကိုယ်တိုင် ကြိုးစားကြည့်

အသုံးပြု အရာဝတ္တု အချက်အလက် အတွက် ဖြစ်ပါသည် မှာ 100 အောက် ဖြစ်လျှင် (input အရာဝတ္တု) min အခွင့် (ပြုပြင်) အား လျှင် သတင်းကြေညာ တစ်ခု ပြသရမည်

rangeUnderflow အခွင့်

<input id="id1" type="number" min="100">
<button onclick="myFunction()">OK</button>
<p id="demo"></p>
<script>
function myFunction() {
  let text = = "Value OK";
  if (document.getElementById("id1").validity.rangeUnderflow) {
    text = "Value too small";
  }
}
</script>

ကိုယ်တိုင် ကြိုးစားကြည့်