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 ?

View Answers

May 10, 2011 at 12:20 PM

<html>
<head>
<script language="JavaScript">
function checkdate(date1,date2){
var validformat=/^\d{4}\-\d{2}\-\d{2}$/ 
var returnval=false
if(!validformat.test(date1.value)){
alert("Invalid Date 1");
document.form.date1.value="";
}
else if(!validformat.test(date2.value)){
alert("Invalid Date 2");
document.form.date2.value="";
}
else{
var start = document.form.date1.value;
var end = document.form.date2.value;

var stDate = new Date(start);
var enDate = new Date(end);
var compDate = enDate - stDate;

if(compDate >= 0)
return true;
else
{
alert("End date should be greater than start date.");
return false;
} 
}
}

</script>
</head>
<form name="form">
<table>
<tr><td>Enter Start Date:</td><td><input type="text" name="date1" ></td></tr>
<tr><td>Enter End Date:</td><td><input type=text name="date2" ></td></tr>
<tr><td><input type="button" onClick="checkdate(this.form.date1, this.form.date2);" value="Check Date"></td></tr>
</table>
</form>
</html>









Related Tutorials/Questions & Answers:
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
php date format yyyy-mm-dd
php date format yyyy-mm-dd  date format yyyy-mm-dd validation
Advertisements
validationrule for date as format yyyy-mm-dd in drools
format yyyy-mm-dd: How i write the validation rule for date as a format yyyy-mm-dd...validationrule for date as format yyyy-mm-dd in drools  Please give...("outofServiceStartDate", "stmpOutOfServiceStartDateInvalid", "Please use the format yyyy-mm-dd
c# current date in yyyy-MM-dd format
c# current date in yyyy-MM-dd format  Hi, How to get the current... format. In c# how to get current date in yyyy-mm-dd format...({}); var dateString = DateTime.Now.ToString("yyyy-MM-dd"); Console.WriteLine
how to format date from yyyy-mm-dd to dd-mm-yyyy
how to format date from yyyy-mm-dd to dd-mm-yyyy  <!DOCTYPE html... "includes/header.php";?> <pre> Enter Date1(yyyy-mm-dd): <input type="text" name="dob1" id="dob1" /> Enter Date2(yyyy-mm-dd): <input type
How to convert date to string in Java in yyyy-mm-dd format
How to convert date to string in Java in yyyy-mm-dd format  Hi, I... to String in yyyy-mm-dd format. How to convert date to string in Java in yyyy... SimpleDateFormat("yyyy-mm-dd"); Then use the format function to DateFormat to convert
How to convert string to date in java in yyyy-mm-dd format?
How to convert string to date in java in yyyy-mm-dd format?  Hi, I have a date in yyyy-mm-dd format. How to convert string to date in java in yyyy... java.util.Date; /* * Example of formatting date in Java * from yyyy-mm-dd formaat
How to format current date into yyyy-mm-dd in Java
How to format current date into yyyy-mm-dd in Java  Hi, I have requirement to format the date into yyyy-MM-dd format for inserting it into MySQL... into yyyy-mm-dd in Java? Thanks   Hi, Following sample code will help
convert yyyy-mm-dd hh mm ss to date in sql
convert yyyy-mm-dd hh mm ss to date in sql  Hi, How to convert yyyy-mm-dd hh mm ss to date in sql? Thanks   Hi, You should use following code in SQL DATE_FORMAT(STR_TO_DATE(my_date, "%Y/%m/%d %H:%i:%s.%f"), "%Y-%m
get current date in java in yyyy mm dd hh mm ss format
get current date in java in yyyy mm dd hh mm ss format  Hi, I want to get the current date into string yyyy mm dd hh mm ss format. How to get current date in java in yyyy mm dd hh mm ss format in a Java program? Thanks  
Java convert string to date from format yyyy-mm-dd hh mm ss
Java convert string to date from format yyyy-mm-dd hh mm ss  Hi, I have date in the string yyyy-mm-dd hh mm ss format. Now I will want this string date into the date format. How to convert string to date from format yyyy-mm-dd
javascript
javascript  hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format using javascript, and when i click on button then number of days should be display in textbox
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
Validating date in javascript - Java Interview Questions
sample code validating date in javascript using text box. thank u in advance  In what format you are going to enter the date in Text box (i.e : dd/mm/yyyy or mm/dd/yyyy or yyyy/mm/dd
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation
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 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  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
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<
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 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
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">
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
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>
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
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 Email Validation
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
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,ADS_TO_REPLACE_1 Try the following code
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 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
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
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.... Alphanumeric validation means a field in the form can accept only numbers
combox validation javascript code - JSP-Servlet
combox validation javascript code  hiiiiiii, I want a javascript code for combobox field validation for my Lotus Notes web page.... thnx  Hi This is the source code of combobox validation in javascript
PHP JavaScript form Validation - PHP
PHP JavaScript form Validation  Just looking for a general PHP JavaScript form Validation. How can I write external JavaScript Validation? Please suggest!  Hi Friend, 1) form Enter Name Enter Address
javascript-email validation - Java Beginners
javascript-email validation  give the detail explanation for this code: if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr... about email validation at: http://www.roseindia.net/jsp/valid-email-jsp.shtml
javascript date validation using regex
format.Please Input in (dd/mm/yyyy) format!"); return false; } <... of textBox..</h2> Enter Date(dd/mm/yyyy): <input type="text" name="date" id... Input in (dd/mm/yyyy) format!"); return false; } </script>
start date and end date validation in javascript - Ajax
start date and end date validation in javascript  hi, i am doing web... validations in javascript. end date should be greater than start date if so less than... in google and i got some scripts but it is not good validation.  
Mysql Date Type
the 'emp_dob ' records in 'yyyy-mm-dd' format. select emp_dob from employee: The select query return the emp_dob  records in "yyyy-mm-dd" format...; Mysql Date Type is used to show the date in "yyyy-mm-dd" format.The
JavaScript password validation
JavaScript password validation We are going to discuses about JavaScript password special characters validation. In this example we have created one "... used JavaScript password validation and check for an alphabet , number
javascript
javascript  Hi deepak, how to write form validation on javascript
Mysql Date Expression
a format  'YYYY-MM-DD' and 'HH.MM.SS'. Timestamp columns are displayed
Form Validation With Java Script
the Validation in  JavaScript and  your Validation in JavaScript program... Form Validation With Java Script   .... It is the most important features in JavaScript . It provide the facilities 
regarding date field validation - Ajax
not get submitted and if the date format is changed to yyyy/dd/mm or yyyy/mm/dd... should be : mm/dd/yyyy") return false } if (strMonth.length<1... a Date (mm/dd/yyyy
please send me javascript validation code - Java Beginners
please send me javascript validation code  hallo sir , please send me java script code for this html page.since i want to do validation.i am a new user in java ....please send me its urgent
URL validation in JavaScript
URL validation in JavaScript In this tutorial we are going to discuss, how to validate a URL in JavaScript. Java Script is a Scripting language. A Java Script language is a lightweight programming language. JavaScript code are written
how do i apply the javascript validation functions to the iframe content?
how do i apply the javascript validation functions to the iframe content?  Hi friends am Yogesh Nandane..Developing a small accessibility evaluation...;script type="text/javascript"> function test() { iframe
how do i apply the javascript validation functions to the iframe content?
how do i apply the javascript validation functions to the iframe content?  Hi friends am Yogesh Nandane..Developing a small accessibility evaluation...;script type="text/javascript"> function test() { iframe

Ads