1. Custom method:
2. Manually trigger the OnChange method with JS
When the input box is assigned a value by JS, the onchange method of the input box is not triggered by default, which can be triggered manually with JS.
<input type= "text" onchange= ' Test () ' Onblur= "Checkdata (This)"/><script type= "Text/javascript" >//verifying that the data is in the correct format functionCheckdata (obj) {varval =Obj.value; if(val! = ""){ //up to 12 digits before the decimal point, 1-2 digits after the decimal point varReg =NewREGEXP (/^\d{0,12} (\.\d{1,2})? $/); varresult =Reg.test (Val); if(!result) {//data that is not conformingObj.value = ""; Obj.onchange ();//manually triggering the OnChange method } } } //test whether the OnChange method executes functionTest () {alert (The OnChange method executes the); } </script>
Common JS Summary (supplement: 2016-09-21)