date format in javascript

date format in javascript

display date format as dd/mm/yyyy and day could take only between 01-31 & month could take only between 01-12 & year could take only between 1990-2090. i use this script, bt i could n't. please help me. thank u

var date=/^\d{2}\/\d{2}\/\d{4}$/ if(document.userform.joindate.value.search(date)==-1) { alert("please enter date format as dd/mm/yyyy"); document.userform.joindate.focus(); return false; }

View Answers

February 21, 2012 at 3:14 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:
date format in javascript
date format in javascript  display date format as dd/mm/yyyy and day... help me. thank u var date=/^\d{2}\/\d{2}\/\d{4}$/ if(document.userform.joindate.value.search(date)==-1) { alert("please enter date format as dd/mm/yyyy
Date format - Date Calendar
Date format  Hi All, I am getting a date from database as a format 2010-15-07.I need to change it to 07/15/2010 and display it on my date field.Every time i need to check the format of the date field and make sure the correct
Advertisements
date format - Date Calendar
date format  how to convert dd-mmm-yyyy date format to gregorian calendar format in JSP please tell me the code  Hi friend, Code...="19-Sep-2008"; DateFormat format ; Date date ; format = new
Date format - Date Calendar
Date format  please convert dd-mmm-yy date format to gregorian calendar date format.  Hi friend, Code related your Problem: import...]); Calendar calendar = new GregorianCalendar(pdt); Date time = new Date
php date format change
php date format change  How to change the date format in PHP
convert current date into date format
convert current date into date format  How to get current date and convert into date format in Java or PHP
date_format()
date_format() date_format alias DateTime::format function returns date formatted according to given format. It returns formatted date on success otherwise False on failure. Description on date_format() PHP public string DateTime::format
php date format validation
php date format validation  How to validate the date field in specific format in PHP
String to date with no format
into a date .. this is simple .. but i want to do it without knowing the date format... date format can be (mm-dd-yyyy) if the 99th record also was 06-06-2006 the result should be date format can be (mm-dd-yyyy;dd-mm-yyyy) can sum1 please help me
select date in desired format
select date in desired format  how to select date from the database in DD/MM/YYYY format, because if i am trying select data from the database i am getting value in yyyy/mm/dd and time format like below "2012-05-07 00:00:00.0
java format date
java format date  Hi, How can I format the date in the following...) { Date date=new Date(); SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); String formattedDate=sdf.format(date
Date auto format
Date auto format  Hi, I have jsp page and Date field with input type. Requirement is, if we enter date as MMDDYY or MMDDYYYY and clicking the tab the date(MMDDYY or MMDDYYYY) have to auto format to MM/DD/YYYY. could you please
javascript tomorrow date.
javascript tomorrow date.  Hi, how can I display tomorrow's date using javascript?   <html> <head> <title>Date after... Date() it shows the current date in standard format with current
String to Date format
String to Date format  My Date format is String Eg(Jan 20 2011 ).... How to Change This values Like to database date format Eg(2011-01-20) using..."; Date date=new Date(d); SimpleDateFormat sdf=new
php date format am pm
php date format am pm  how to set the date format that will display the date in both am pm format
NSDateformatter format Date
NSDateformatter format Date  Hi, What is the correct way of writing NSDateFormatter in string format. Thanks.   For current Date in NSDate... that represent other data types. For example to show the date in string format we'll
javascript yesterday date.
javascript yesterday date.  Hi, How can I display the yesterday's... date</title> <script type="text/javascript"> var mydate= new Date...;/head> </html> Description: In javascript whenever you write new Date
javascript current date and time.
javascript current date and time.  How can we display current date...;Current date and time</title> </head> <script type="text/javascript... write new Date() it shows the current date in standard format
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.  ... whenever you write new Date() it shows the current date in standard format
Hibernate Date Format
This section contains description of Hibernate Date Format
date format - Java Beginners
date format  how to 45day in dd-mmm-yyyy date format.  Hi...-yyyy", Locale.US); Date d = sdf.parse(timestamp); Calendar cal..."; System.out.println("Date is : " + timestampToParse); Calendar cal = parseTimestamp
javascript date comparison
javascript date comparison  How to compare dates and display... language="JavaScript"> var date1 = new Date("jan, 25, 2010"); var today... write new Date() it shows the current date in standard format with current day
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
javascript date difference in months
javascript date difference in months  How can I find the difference...; <head> <script type="text/javascript"> var date1=new Date(); var...; Description: In javascript whenever you write new Date() it shows the current date
javascript date difference in days.
javascript date difference in days.   I want to find the difference between two dates in terms of days. I am using javascript. Please help.  ... Date() it shows the current date in standard format with current day
JavaScript Validate UK Date
JavaScript Validate UK Date  How to Validate UK Date in JavaScript...{1,2}\/\d{4}$/ //Basic check for format validity var returnval=false if (!validformat.test(input.value)) alert('Invalid Date Format
Date object using JavaScript
Date object using JavaScript  What's the Date object using JavaScript
Date not getting in proper format
Date not getting in proper format  import java.util.*; class Date { public static void main(String[]args) { Date d = new Date(100000000000L); System.out.print("1st date"+d.toString()); } } out put:- 1st date@3e25
date format updated
date format updated  package LvFrm; import java.awt.Color; import... panel1,panel2,panel3,panel4; Font f1; JComboBox i1,j1,k1; JButton b1,b2; //for date...); panel2.setBorder(b2); frm.add(panel2); /*for date entry & adding
javascript questions on date
javascript questions on date  how to add some days to an existing date
Mysql Date Format
Mysql Date Format       Mysql Date Format explains you the way of formatting Date... Date Format'. To understand this example we show you the following Syntax used
date format - Java Beginners
date format  How to convert yyyy-mm-dd to dd-mmm-yyyy  Hi... void main(String args[]) throws Exception{ Date todaysDate = new java.util.Date...-dd date is ==>"+formattedDate); Date date1 = formatter.parse
date format - JSP-Servlet
date format  how to convert 2008-10-14 to 14-Sep-2008   Hi..."; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date dateStr...); System.out.println("yyyy-MM-dd date is ==>"+formattedDate); Date
Date Format required to change in java
Date Format required to change in java  can we change the format of date like sql as per our requirements???If yes then please give the detail solution
JavaScript parse date
JavaScript parse date..., you will learn how to parse the date in JavaScript. JavaScript provides the function parse() that takes a date in string format and returns the equivalent
Change Date Format - Development process
Change Date Format   Hi, i hav used following line get date field from database . But my output is 2009/26/5. How to change the format
date_parse_from_format
  date_parse_from_format date_parse_from_format function returns... date_parse_from_format ( string $format , string $date ) Parameters of Date Parse Function PHP format - Format accepted by date() with some extras. date
Change Date Format - Development process
Change Date Format  Hi, While retrieving data frm database, date format displayed as yyyy/mm/dd but i want to display as dd/mm/yyyy. I have tried parse,format functions but not getting output. can u send me code
Simple Date Format Example
Following is a simple date format example made using Format class. We have uses a pattern of special characters to date and time format. In this example, SimpleDateFormat:class is used to format date into text and parse text into date
Sql Date and Time Format
Sql Date and Time Format     ...; is used to  format date and time.  SYNTAX:- DATE_FORMAT(date,format)ADS..._Format(date,format) Query return you the format date in the order of Week,Day
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">
Formatting a Date Using a Custom Format
Formatting a Date Using a Custom Format In this section, you will learn how to format a date using a custom format. Java has provide many classes that allow a programmer to format the date and time. Here we have used SimpleDateFormat
php date format yyyy-mm-dd
php date format yyyy-mm-dd  date format yyyy-mm-dd validation
Date Format Example
Date Format Example       This example shows how to format Date using Format class. In this program we use a pattern of special characters to date and time format
Java Date Format Example
Java Date Format Example You can format date in many ways. In this tutorial Format class is used to format the java date in to the different formats... in the following ways. 1. Create an object of Format class. 2. Set The required date
struts2.2.1 date Format example
struts2.2.1 date Format example. In this example, We will discuss about the different type of date format using struts2.2.1. Directory structure of example...; <title>Date Format Example</title> </head>ADS_TO_REPLACE_2
date format to be updated with current date time
date format to be updated with current date time  package LvFrm...; JButton b1,b2; //for date month year entry String strD[]={"Day","1...); /*for date entry & adding date into panel 2 also addind panel
Mysql Date Format
Mysql Date Format      .... The Tutorial helps you to write the Date Format in SQL Query.  date_format...:- mysql> select date_format(now(),'%e %M %W %Y'); Output
ModuleNotFoundError: No module named 'date-format-machine'
ModuleNotFoundError: No module named 'date-format-machine'  Hi, My... named 'date-format-machine' How to remove the ModuleNotFoundError: No module named 'date-format-machine' error? Thanks   Hi
ModuleNotFoundError: No module named 'date-format-machine'
ModuleNotFoundError: No module named 'date-format-machine'  Hi, My... named 'date-format-machine' How to remove the ModuleNotFoundError: No module named 'date-format-machine' error? Thanks   Hi

Ads