Saturday, July 11, 2020
therichposts@gmail.com
Jquery

Jquery Mobile validation On Text Field With keydown Event

Jquery Mobile validation On Text Field With keydown Event

Views

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

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, Angular 8, Angular 9, Angular 10 Nodejs, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.