I am trying to fix some javascript error of contact form while user trying to enter the contact number they cant able to correct or cant able use backspace key in firefox only. In chrome it is working completely fine
here is my code
CG = (function(){
var
_isNumeric = function(evt){
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if(charCode >= 48 && charCode <= 57)
return true;
return false;
},
_isDecimal = function(evt){
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if((charCode >= 48 && charCode <= 57) || charCode==46)
return true;
return false;
},
_alphanumeric = function(evt){
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
return ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || charCode == 8 || charCode == 32 || (charCode >= 48 && charCode <= 57));
};
return{
isDecimal:_isDecimal,
isNumeric:_isNumeric
}
});
$(document).ready(function(){
$("input[type=text]").on("keypress",".isDecimal",function(e){
return CG.isDecimal(e);
});
$(document).on("keypress",".isNumeric",function(e){
return CG.isNumeric(e);
});
$(document).on("keypress",".alphanumeric",function(e){
return CG.alphanumeric(e);
});
$(document).on("keypress",".isDecimal",function(e){
return CG.isDecimal(e);
});
})
Aucun commentaire:
Enregistrer un commentaire