Home Answers Viewqa JavaScriptQuestions JavaScript regex validate Mobile no.

 
 


Java Coder
JavaScript regex validate Mobile no.
2 Answer(s)      a year ago
Posted in : JavaScript Questions

JavaScript regex validate Mobile no.

View Answers

May 12, 2012 at 1:40 PM


<html>
<head>
<title>Mobile number validation using regex</title>
<script type="text/javascript">
    function validate() {
        var mobile = document.getElementById("mobile").value;
        var pattern = /^\d{10}$/;
        if (pattern.test(mobile)) {
            alert("Your mobile number : "+mobile);
            return true;
        } 
            alert("It is not valid mobile number.input 10 digits number!");
            return false;

    }
</script>

</head>
<body>
<h2>Validating mobile number..</h2>
Enter Mobile No. :
<input type="text" name="mobile" id="mobile" />
<input type="submit" value="Check" onclick="validate();" />
</body>
</html>

May 12, 2012 at 1:41 PM


The above example validate 10 digit (eg-9675647324) mobile number

by using regular expression- /^\d{10}$/;


Here /../(forward slashes) is used to quote your regular expression.

^ shows beginning of string.

\d{10} shows any digit 0-9 having 10 places.

$ is used for ending the string.

Test() method takes one argument and check that to the pattern.









Related Pages:
JavaScript regex validate Mobile no.
JavaScript regex validate Mobile no.  JavaScript regex validate... validate() { var mobile = document.getElementById("mobile").value...="mobile" id="mobile" /> <input type="submit" value="Check" onclick="validate
JavaScript regex validate validate Zip.
JavaScript regex validate validate Zip.  JavaScript regex validate - how to validate Zip?   <html> <head> <title>Zip Code validation using regex</title> <script type="text/javascript">
javascript regex validate url
javascript regex validate url  How to validate URL in regex Javascript   <html> <head> <title>Url validation using regex</title> <script type="text/javascript"> function validate
JavaScript regex validate Telephone no.
JavaScript regex validate Telephone no.  JavaScript regex validate... validation using regex</title> <script type="text/javascript"> function validate() { var phone = document.getElementById("phone").value
JavaScript regex validate Character
JavaScript regex validate Character  JavaScript regex validate... using regex</title> <script type="text/javascript"> function validate() { var name = document.getElementById("name").value; var
JavaScript regex validate Character
JavaScript regex validate Character  JavaScript regex validate... using regex</title> <script type="text/javascript"> function validate() { var name = document.getElementById("name").value; var
javascript regex validate currency
javascript regex validate currency  How to validate currency in JavaScript?   <html> <head> <title>Currency validation using regex</title> <script type="text/javascript"> function
javascript regex validate Special character
javascript regex validate Special character   javascript regex validate Special character   <html> <head> <title>Zip Code validation using regex</title> <script type="text/javascript">
javascript regex validation alphanumeric
javascript regex validation alphanumeric  How to write javascript regex validation for alphanumeric?   <html> <head> <.../javascript"> function validate() { var name = document.getElementById
javascript regex validation email
javascript regex validation email  How to write JavaScript regex... validation using regex</title> <script type="text/javascript"> function validate() { var email = document.getElementById("email").value
javascript date validation using regex
javascript date validation using regex  Hi, I want to validate the date using javascript. Please help.   <html> <head> <title>Validating Date format</title> <script type="text/javascript">
JavaScript regex exec() method for text match.
JavaScript regex exec() method for text match.  JavaScript regex exec...; regex exec() for text matching</title> <script type="text/javascript"> function validate() { var name = document.getElementById("name
JavaScript Validate UK Date
JavaScript Validate UK Date  How to Validate UK Date in JavaScript   <SCRIPT> function validateDate(dtControl) { var input = document.getElementById(dtControl) var validformat=/^\d{1,2}\/\d
validate radio button using javascript
validate radio button using javascript  validate radio button using javascript
validate select tag items in javascript
validate select tag items in javascript  Hi, How to validate addition of two numbers from two different <select> tag items in JavaScript..? Thanks in advance
Validate <select> tag Items
Validate select tag Items  Hi, How to validate addition of two numbers of two different "select" tag items in JavaScript..? Thanks in advance
Validate <select> tag Items
Validate select tag Items  Hi, How to validate addition of two numbers of two different "select" tag items in JavaScript..? Thanks in advance
Javascript Form validation Example
Javascript Form validation Example In this section we will discuss about how to validate your application form in javascript. In many applications data... inserted is correct or not you will be required to validate your form. Here I
JAVASCRIPT
JAVASCRIPT  I have one textbox and I want to validate that it must start with number(1-0). can anyone tell me a javascript for that ? thanks in advance
how to validate the telephone number without using jquery in html with javascript
how to validate the telephone number without using jquery in html with javascript  how to validate the telephone number without using jquery in html with javascript
simple javascript validation for numbers
; <title>Mobile number validation using regex</title> <script type="text/javascript"> function validate() { var mobile...simple javascript validation for numbers  simple javascript
JavaScript validate select tag
JavaScript validate select tag In this tutorial, you will learn how to validate html select tag. Here, we have used two select tags to select numbers...; <script language = "Javascript"> function validate
Javascript
" method="post" onsubmit="javascript:return validate();"> Phone Number:<... this format xxx-xxx-xxxx, i want the code in javascript. as a function.   Javascript Phone Number Validation <html> <script> function
javascript
javascript  please tell me sir,this query not validating correctly..whats wrong in this query? <HTML> <HEAD> <TITLE>validate <Script language = JavaScript> function validate(theForm) { var why=""; why
javascript
javascript  <HTML> <HEAD> <TITLE>validate <Script language = JavaScript> function validate(theForm) { var why=""; why... = JavaScript> function validate() { var checkD= checkDropdown
On Javascript
fields, Example. to check for blank field, number validation for salary, mobile
javascript
javascript  Hi deepak, sample example on javascript form validation... charachters accepted are A - Z and a - z");return 0;} } function validate... name="form" method="post" onsubmit="return validate();"> <table> <
Validate
Validate   hi all..im a beginner java and i need some help from u guys.. Its about validate. My HR request BF = 'brought forward', leave cannot apply date greater than 31/03 of particular year. So, if the user apply the date
Java REGEX
Java REGEX  I have a String {"name":"ashish","surname":"singh"} I have to check whether each word is surrounded by the " (double quotes) or not using the java regex. without using Json lib. Kindly help
How do i validate form using javascript and send data to database?
How do i validate form using javascript and send data to database?  I need a "JOIN US" form that can validate using javascript and be able to connect....") return false; } } return true } function validate(){ var
How to Validate dynamically created text box in HTML using Javascript
How to Validate dynamically created text box in HTML using Javascript  Here is the HTML code to create text boxes dynamically. It works properly.... And also how to validate the text boxes created dynamically. <html>
Calling In JavaScript Functions from HTML Form To Validate User Entered Data
Calling In JavaScript Functions from HTML Form To Validate User Entered... and editing my html to call my functions to validate the user entered data...;title>Subscription Form</title> <script type="text/javascript">
replacing regex in large files
replacing regex in large files  replacing regex in large files
Flex Mobile Application Development
Flex Mobile Application Development The invention of mobile phone can be considered as the biggest invention of this decade because mobile phone became the mother of several other technologies like mobile chip manufacturing technology
how to validate values in the dynamically created textboxes?
how to validate values in the dynamically created textboxes?  how to validate values in the dynamically created textboxes in HTML using javascript...;script language="javascript"> var n=1; //FUNCTION TO REMOVE TEXT BOX ELEMENT
jQuery to validate Email Address
jQuery to validate Email Address     ... that validate the email address  from server and displays on the user browser...: The following code includes the jQuery JavaScript library file: <script type
Recursive regex PHP - PHP
Recursive regex PHP  any one? that can send me the code of regular expression that checks other regular expression for its correctness.   Hi, Please check at http://www.roseindia.net/tutorial/php/phpbasics/PHP
JavaScript - JavaScript Tutorial
JavaScript Tutorials is one of the best Quick reference to the JavaScript. In this JavaScript reference you will find most of the things about java script. JavaScript tutorial is classified into sections with examples. This tutorial
JavaScript - JavaScript Tutorial
JavaScript Tutorials is one of the best Quick reference to the JavaScript. In this JavaScript reference you will find most of the things about java script. JavaScript tutorial is classified into sections with examples. This tutorial
JavaScript calculate age from date of birth
); var pattern = /^\d{1,2}\/\d{1,2}\/\d{4}$/; //Regex to validate date...JavaScript calculate age from date of birth  How to calculate age.../javascript"> function ageCount() { var date1 = new Date
javascript validation
javascript validation  i have 4 buttons in my project like save,find,modify,clear and exit. Here my problem is i have to validate in javascript like if i click on save button an alert message should be displayed "DO YOU WANT
javascript - Java Interview Questions
javascript  I am writing a simple JavaScript to validate the field. Any guidelines for writing a simple JavaScript will work
Java: Regex Exercises 1
Java: Regex Exercises 1 Name _______________________________ Assume String subject = "This is test 123 of <a href="http://here.there.tld">Hello</>"; String regex; String result; . . . Pattern pat = Pattern.compile(regex
Mobile Skins Design Services
Mobile Skins Design Services Mobile Skins are all electronic devices that provide a new and attractive look to mobile phones. It is designed for deploying it on the back of the mobile, keypad, corner or edge and even full body coverage
long validate
long validate  How to validate long type
JavaScript - JavaScript Tutorial
how to immediately put JavaScript to validate forms, calculate values, work... is JSP using JavaScript I this example we will show you how to validate...JavaScript - JavaScript Tutorial JavaScript Tutorials is one
how to validate e,ail id and phne number in student form
="javascript:return validate();"> <table> <tr><td>Email <...how to validate e,ail id and phne number in student form  how to validate e,ail id and phne number in student form   Hi Friend, Try
JavaScript validation for decimal number
JavaScript validation for decimal number Here we are going to validate... in the textbox, the javascript takes the value of textbox and check...;) } } function validate(){ var dec=document.form.num.value

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.