Hello to all, welcome to therichpost.com. In this post, I will tell you, Jquery Mobile validation On Text Field With keydown Event. Most of my code is full with jquery. When I stuck in php or other language then that stuckness I remove with jquery code.
With this jquery code only number will be add in text box and shift+ will be add and mobile number could be(+981111111111).
Alphabets will not be add with this jquery mobile validation script:
Here is the working code for Jquery Mobile validation On Text Field With keydown Event and you need to add this into you jquery script:
/*Mobile field validation*/
$(“.txtboxclassname”).keydown(function (e) {
// Allow: backspace, delete, tab, escape, enter and .
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
// Allow: Ctrl+A, Command+A
(e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) ||
// Allow: home, end, left, right, down, up
(e.keyCode >= 35 && e.keyCode <= 40) ||
// Allow: Plus for mobile no
(e.keyCode == 187)) {
// let it happen, don’t do anything
return;
}
// Ensure that it is a number and stop the keypress
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
});
There are so many jquery code, tricks and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com
Recent Comments