Allow only numbers to be typed in a textbox

You could subscribe for the onkeypress event:
<input type="text" class="textfield" value="" id="extra7" name="extra7" onkeypress="return isNumber(event)" />

and then define the isNumber function:
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;
}
<input type='number' class='qty' name='' value='' min='0' max='99' onkeypress='return isNumberKey(event, false)' /></td>
function isNumberKey(evt, decimal) {
        var charCode = (evt.which) ? evt.which : evt.keyCode
        if (decimal == true && charCode == 46)
            return true;

        if (charCode > 31 && ((charCode < 48 || charCode > 57) || (charCode >= 96 && charCode <= 105)))
            return false;
        return true;
    }

Popular posts from this blog

Yii Framework In Update Time View Image In Form

Add a new column to existing table in a migration

Ajax Toggle(on/off) on-click Update