Javascript to validate minimum legth
The below code will allow only two character
onkeypress="this.value= this.value.replace(/[^0-9]/g, '');return limitKeypress(event,this.value,2)"
function limitKeypress(event, value, maxLength) {
if (value != undefined && value.toString().length >= maxLength) {
event.preventDefault();
}
}
The below code will allow only two character
onkeypress="this.value= this.value.replace(/[^0-9]/g, '');return limitKeypress(event,this.value,2)"
function limitKeypress(event, value, maxLength) {
if (value != undefined && value.toString().length >= maxLength) {
event.preventDefault();
}
}
No comments:
Post a Comment