How to call a function using
onkeypress
in a textfield. Below is the code for validation :
function isNumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
}
Below is the code for the textfield :
<?php echo $form->textField($model,'min_size', array('placeholder' => 'Min Sqft', 'style'=>'width:100px','onkeypress'=>'isNumber(event)')); ?>
How can i pass the value and pass the script.