1, to determine the legality of input value entered there are many ways that I used here is the judge in the onchange, code is as follows: [All major browsers support]
<input type="text" name="input_grjcjs"'+ ' onchange="setValueChange(this,"'+grzh+'",'+r.ROW_ID+','+r.GRZHZT+','+r.GRYJCE+','+r.DWYJCE+ ','+r.YJCEHJ+','+tw+')" grjcbl="'+r.GRJCBL+'" dwjcbl="'+r.DWJCBL+'" value="'+data+'" '+ dis+ ' class="form-control">
2, js Code:
function setValueChange (e, grzh, rowid , grzhzt, gryjce, dwyjce, yjcehj, this_who) {
value after the change //
var this_val = e.value || 0;
before changing the value of //
var old_val = e.defaultValue;
/ /
var REG = / ^ [0-9] + [0-9] * $ /;.? // determines whether the string is digital
IF (! reg.test (this_val)) {
// If the user input is not a character put the string value to the original value changes
e.Value = old_val;
return to false;
}
}
3, may also be used oninput = "value = value.replace (/ [^ \ d] / g, '')" to verify input does not support the following IE9 Firefox 4.0 does not support what is used as follows:
<input type="text" name="tel" oninput = "value=value.replace(/[^\d]/g,'')" maxlength="11"/>