mardi 4 août 2015

can't use backspace and del in textbox when open in mozilla

I have problem to use textbox validation using js, this my source:

<script>
    $(document).ready(function () {
        $("#letnd").keypress(function (e) {
    
            var regex = new RegExp("^[a-zA-Z]+$");
            var key = String.fromCharCode(!e.charCode ? e.which : e.charCode);
    
            if (!regex.test(key)) {
                e.preventDefault();
                return false;
            }
        });
    
        $("#letnb").keypress(function (e) {
        var regex = new RegExp("^[a-zA-Z]+$");
        var key = String.fromCharCode(!e.charCode ? e.which : e.charCode);
        if (!regex.test(key)) {
           e.preventDefault();
           return false;
        }
       });
    });
    </script>
    <input id="letnd" type="text" name="txtnd" />
    <input id="letnb" type="text" name="txtnb" />

In other browsers, this code work fine, but why when I open it in mozilla the textbox can't use backspace and del?

Aucun commentaire:

Enregistrer un commentaire