Skip to content
Advertisement

Validation for 10 digit mobile number and focus input field on invalid

I need the code for validating email and mobile number in jQuery and also focus() on that particular field where validations are not satisfied.

This is my query

JavaScript

Advertisement

Answer

for email validation, <input type="email"> is enough..

for mobile no use pattern attribute for input as follows:

JavaScript

you can check for more patterns on http://html5pattern.com.

for focusing on field, you can use onkeyup() event as:

JavaScript

and your HTML code should be:

JavaScript
Advertisement