onkeypress event
-
Hello people! I have a scritp to allow only numbers in a phone field.
If I use this script directcly in a <input> field, it works fine, but an error appears when I use it the [tel] structure.This is the code:
<!-- header --> <script language=javascript> function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } </script>
It works fine here but CF7 doesn’t validate the tel field:
<!-- input field --> <input id="nunChar" onkeypress="return isNumberKey(event)" type="tel" name="my_phone" minlength="11" maxlength="11" placeholder="00112223334">
It doesn’t work here:
<!-- CF7 tel field --> [tel* pk_numero_cuit id:nunChar onkeypress:"return isNumberKey(event)" minlength:11 maxlength:11 placeholder "00112223334"]
The question is where exactly should the code [ onkeypress=”return isNumberKey(event)” ] be placed ??
Thanks in advance for your kind help.
- The topic ‘onkeypress event’ is closed to new replies.