Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions javascript date validation using regex

Have Programming Question? Ask it here!
 
 
 


ratna rathor
javascript date validation using regex
1 Answer(s)      2 years and 2 months ago
Posted in : JavaScript Questions


Hi,

I want to validate the date using javascript. Please help.


Advertisement
View Answers

May 15, 2012 at 1:18 PM


<html>
<head>
<title>Validating Date format</title>
<script type="text/javascript">
    function validate() {
        var date = document.getElementById("date").value;
        var pattern = /^\d{1,2}\/\d{1,2}\/\d{4}$/;   //defining pattern for date
        if (pattern.test(date)) {
            alert("Entered date : "+date);
            return true;
        } 
            alert("Invalid date format.Please Input in (dd/mm/yyyy) format!");
            return false;

    }
</script>

</head>
<body>
<h2>Validating Alphanumeric value of textBox..</h2>
Enter Date(dd/mm/yyyy):
<input type="text" name="date" id="date" />
<input type="submit" value="Check" onclick="validate();" />
</body>
</html>

Description: This example has date formate like dd/mm/yyyy.you can define another format too. Here /../(forward slashes) is used to quote your regular expression. ^ shows beginning of string. \d is for any digit 0-9. . is used for period. \d{1,2} having any digits(0-9) of 1 or 2 size (eg: 2 or 12). $ is used for ending the string. test() method takes one argument and check that to the pattern.



Related Tutorials/Questions & Answers:
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 validation alphanumeric
javascript regex validation alphanumeric  How to write javascript regex validation for alphanumeric?   <html> <head> <title> alphanumeric validation using regex</title> <script type="text
Advertisements
javascript regex validation email
javascript regex validation email  How to write JavaScript regex validation for email?   <html> <head> <title>Email validation using regex</title> <script type="text/javascript">
start date and end date validation in javascript - Ajax
start date and end date validation in javascript  hi, i am doing web surfing project. pls guide me for my project. i want start date and end validations in javascript. end date should be greater than start date if so less than
JavaScript regex validate Telephone no.
JavaScript regex validate Telephone no.  JavaScript regex validate Telephone no.    <html> <head> <title>Phone number 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
Date object using JavaScript
Date object using JavaScript  What's the Date object using JavaScript
JavaScript regex validate Mobile no.
validation using regex</title> <script type="text/javascript"> function...JavaScript regex validate Mobile no.  JavaScript regex validate... 10 digit (eg-9675647324) mobile number by using regular expression- /^\d{10
JavaScript regex validate Character
JavaScript regex validate Character  JavaScript regex validate Character.   <html> <head> <title>Character validation using regex</title> <script type="text/javascript"> function
JavaScript regex validate Character
JavaScript regex validate Character  JavaScript regex validate Character   <html> <head> <title>Character validation using regex</title> <script type="text/javascript"> function
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 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">
how to give validation using javascript in swing
how to give validation using javascript in swing   how to give validation using javascript in swing....... can somebody give code for username and password validation using javscript and swing
javascript regex validate Special character
Code validation using regex</title> <script type="text/javascript">...javascript regex validate Special character   javascript regex... digit (eg- 12345-2323) zip code by using regular expression- /^\d{5
date validation
date validation  sir, pls provide date validation code in javascript..we want to include it into our master form..   Please visit the following link: http://www.roseindia.net/mysql/datevalidation.shtml
Date Validation
Date Validation  Hi, I need Date Validation using java in spring framework. Please Anyone help me... Thanks in advance
Date validation in JSP
how to use date validation in a JSP page. Here in this code we are using JavaScript for validating date in a specified format as "MM/DD/YYYY". We... Date validation in JSP       Example
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
Date validation
Date validation  How to validate date in jsp? That is i have a textbox which will have the value from the date picker. How to validate the date... the following links: http://www.roseindia.net/javascript/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">...; } </script> </head> <body> <h2>Matching pattern using
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
javascript validation
javascript validation  my problem is following code is my form i want validation and for email field it will check formate useing regularexpressions. <html> <script src="combovalidate1.js" type="text/javascript
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation
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 validation
javascript validation  I need to validate password with following...;/script> <script language="javascript"> function...;<INPUT id=register type=button value=Submit name=Submit onclick='javascript
yyyy-mm-dd validation in javascript
yyyy-mm-dd validation in javascript   My form return value like (2011-10-05)yyyy-mm-dd ... my End date greater than my start date.. How to do validation in javascript
javascript for websites url validation
javascript for websites url validation  javascript for websites url validation   JavaScript Code for URL Validation **function isvalidurl(url) { return url.match(/^(ht|f)tps?:\/\/[a-z0-9-.]+.[a-z]{2,4}\/?([^\s<
simple javascript validation for numbers
simple javascript validation for numbers  simple javascript validation for register number   Here is a html code that accepts number from...; <title>Mobile number validation using regex</title> <script
Javascript validation code
Javascript validation code  Hi, I need a javascript validation code for the following fields 1)Name 2)Email 3)Mobile 4)City 5)State 6)Product type 7)submit button All should display enter the field required(like name required
Javascript validation code
Javascript validation code  Hi, I need a javascript validation code for the following fields 1)Name 2)Email 3)Mobile 4)City 5)State 6)Product type 7)submit button All should display enter the field required(like name required
javascript date picker - Date Calendar
javascript date picker  how to insert a date picker user control in a html/jsp using javascript??? please help, it's urgent.  Hi Friend, Please visit the following links: http://www.roseindia.net/javascript
php date format validation
php date format validation  How to validate the date field in specific format in PHP
Email validation is JSP using JavaScript
Email validation is JSP using JavaScript... will show you how to validate email address in you JSP program using JavaScript... will do the email validation using the function emailcheck(). The funcation
JavaScript Email Validation
; In this section we are going to check email Validation using JavaScript. JavaScript allows to perform a client side validation of email Ids in several forms... JavaScript Email Validation
Registration page with JavaScript Validation
Registration page with JavaScript Validation   HTML Registration page with JavaScript Validation - required source code   Registration page in HTML with JavaScript Validation source code <html> <head>
Validation probs in javascript
Validation probs in javascript  This is my sports1.jsp file <...; <HTML> <head> <SCRIPT language="javascript">... file my validation works correctly but when my validation fails i am getting
Javascript validation - Java Beginners
Javascript validation  Hi I have developed the following function for the validation of Zip code,the problem is, when user enters the valid zip code in first attempt, the background color of text box changes to green while I
Display current date in text box in JSP using javascript
Display current date in text box in JSP using javascript In this section you will learn how to display current date in text box using JavaScript.For this purpose, we have used JavaScript Date object. The getDate() method returns the day
javascript tomorrow date.
javascript tomorrow date.  Hi, how can I display tomorrow's date using javascript?   <html> <head> <title>Date after current date</title> <script type="text/javascript"> var mydate= new
Form Validation with JavaScript
Form Validation with JavaScript  I created a simple form including nine or ten fields in HTML, and i want to validate it in JavaScript. How can i do it? Thanks!!   Hi Friend, Try the following code: 1)register.html
regarding date field validation - Ajax
for this and thanks in advance.  Hi friend, date validation in javascript...regarding date field validation  i have developed user information page for a site, all the fields are valid except date field. i want the date in dd
Form Validation using Regular Expressions is JavaScript
Form Validation using Regular Expressions is JavaScript... is JavaScript validation using Regular Expressions? The JavaScript Validating... =  /pattern/[switch] Using JavaScript Validation
javascript form validation
javascript form validation  How to validate radio button , dropdown list and list box using onsubmit event..please give me a sample example..If we do not select any option,it shows an error..   Hello Friend, Try
Javascript validation - Java Beginners
Javascript validation  Hi, this is ragav and my doubt is: I am having a input type="file" text box in which the user can browse the required... or not in javascript? plz urgent..   Hi Friend, Try the following code
javascript date difference in years
javascript date difference in years  I want to find the difference between two dates with respect to years. I am using javascript. Please help.  ... with current day,date,time and GMT.you can also specify your own date by using new Date
Alphanumeric Validation in JavaScript
Alphanumeric Validation in JavaScript In this tutorials we will discuss about alphanumeric validation in JavaScript. Sometimes it may occur when user have... box named registration number in which we have validated it using JavaScript
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page
Form validation in javascript using jsf page  ?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...; <title>view</title> <script type="text/javascript
jquery start date end date validation
jquery start date end date validation  Using JQuery how can i validate the end date and start date? for example if the start date is grater than the end date?   jQuery.validator.addMethod("greaterThan", function(value
javascript date difference in months
javascript date difference in months  How can I find the difference between two dates in terms of months using javascript?   <html> <head> <script type="text/javascript"> var date1=new Date(); var
 

 

 

DMCA.com