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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


arpita rajan patel
date function
1 Answer(s)      3 years and 8 months ago
Posted in : JavaScript Questions


Write a JavaScript program to read a date from user and perform the following, if entered value is date then perform the following 1. Display the day no from the date 2. Display the year from the date 3. Display the month from the date 4. Change the date to next day 5. Change the year to next year 6. change the month to next month


Advertisement
View Answers

March 12, 2011 at 5:41 PM


<html>
<script type="text/javascript">
function checkdate(){
var input=document.getElementById('mydate');
var validformat=/^\d{2}\/\d{2}\/\d{4}$/ 
var returnval=false
if(!validformat.test(input.value))
alert("Invalid Date Format!")
else{ 
var monthfield=input.value.split("/")[0]
var dayfield=input.value.split("/")[1]
var yearfield=input.value.split("/")[2]
document.getElementById("no").value=dayfield;
document.getElementById("month").value=monthfield;
document.getElementById("year").value=yearfield;
document.getElementById("nextno").value=parseInt(dayfield)+1;
document.getElementById("nextmonth").value=parseInt(monthfield)+1;
document.getElementById("nextyear").value=parseInt(yearfield)+1;

var dayobj = new Date(yearfield, monthfield-1, dayfield)
if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
alert("Invalid Day, Month, or Year range!")
else
returnval=true
}
if(returnval==false) input.select()
return returnval
}
</script>
Enter date (mm/dd/yyyy):<input type="text" id="mydate" />
<input type="button" value="submit" onclick="checkdate();"><br />
<pre>
Day No     <input type="text" id="no">
Month      <input type="text" id="month">
Year       <input type="text" id="year">
Next Day   <input type="text" id="nextno">
Next Month <input type="text" id="nextmonth">
Next Year  <input type="text" id="nextyear">
</pre>
</html>


Related Tutorials/Questions & Answers:
date function
date function  Write a JavaScript program to read a date from user and perform the following, if entered value is date then perform the following 1. Display the day no from the date 2. Display the year from the date 3. Display
php date function - Date Calendar
php date function  Hi, I am new to PHP. I am trying to get date from database. But, every time the date under 1970, it changes to 1970. Im totally confuced.thank u in advance. For example : database: date format
Advertisements
The PHP Date() Function
The PHP Date() Function The PHP date() function is used for formatting... date and time. No installation is necessary for using this function.  Syntax...,  timestamp parameter is used in the date() function. e.g.  The mktime
PHP Date function
PHP Date Function In this section we will show you the different formatting options available in the PHP Date function PHP date() function provides many... using date function as follows:</b>*/ echo ("<br>"
PHP date function
PHP Date() Function PHP Date() function is used to display the date and time in a précised format.  With the help of PHP date function you can format... format is different. There are number of variety provided by PHP in date function
Mysql Date now function
Mysql Date now function       Mysql Date now function is useful when you want to return the current... 'Mysql Date now function'. In this Tutorial we define a now ( ) Query
PHP date add function
PHP Add Date function - date_add or DateTime::add function The date_add function or DateTime::add function adds an amount of days, months, years, hours and seconds to a DateTime object. This function works in PHP 5.3.0 and above
PHP date_create_from_format function
date_create_from_format  function The date_create_from_format function is also known as DateTime::createFromFormat. This function returns new... according to the specified format. Parameters format Format accepted by date
ask how function jCalender - Date Calendar
ask how function jCalender  d, Halo friend, i want to ask how to make this script can run and call JCalender. I want to know how to make private this code.i has already insert plugin in my netbeans. try
How can we get second of the current time using date function?
How can we get second of the current time using date function?  How can we get second of the current time using date function
JavaScript Date Function
JavaScript Date Function Many language provide special functions for Date... the functions. JavaScript Date Function Example: <html> <head>...;<b>Today's date is:</b><br/>"); document.write(Date
PHP Date Function with Example
;l"); ?> Output: Tuesday In PHP date() is a predefined function... about date() function please visit our web page: http://www.roseindia.net/tutorial... Write simple program to display the current date To develop the first
function
function  difference between function overloading and operator overloading
Mysql Date Parse
Mysql Date Parse       Mysql Date is used to parse the string date time in Date Format function and retrieve the date in specified format. Understand with Example The Tutorial
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
date_modify
date_modify() in PHP date_modify or DateTime::modify function modifies... , string $modify ) Parameters of Date Modify Function PHP object... by strtotime(). It returns the modify date time. Description public DateTime
PHP Set Date
DateTime::setDate DateTime::setDate alias date_date_set function is used for resetting the current date of the DateTime object to a different date. It returns... $year, int $month, int $day ) DateTime date_date_set ( DateTime $object, int
PHP date_create
date_create () date_create function returns new DateTime object. It returns DateTime object on success or returns FALSE on failure. This functions was introduced in PHP 5.1.0. Description DateTime date_create ([ string $time
date
date   how to insert date in database? i need coding
date_timestamp_set
date_timestamp_set date_timsestamp_set alias DateTime::setTimestamp function is used for setting the date and time based on an Unix timestamp. Syntax... unixtimestamp - Unix timestamp representing the date. Return Values
date_get_last_errors
date_get_last_errors date_get_last_errors alias DateTime::getLastErrors function returns the warnings and errors while parsing a date/time string... no parameter in this function. Return Values Returns array containing info
date
date  i want difference between the date entered in a jtextfield and the system date in java
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
SQL NOW() Function
SQL NOW() Function         NOW ( ) Function provides you the current date and time... date and time. The Now( ) function return you the current date and time
date_sub
. It returns the modified DateTime. Description of PHP Date Sub Function... be any amount. Example of date_sub() Function in PHP: <?php $date...  date_sub date_sub alias DateTime::sub functions for subtracting
date_parse_from_format
  date_parse_from_format date_parse_from_format function returns associative array with detailed info about given date. It is used for accessing info..._format ( string $format , string $date ) Parameters of Date Parse Function PHP
Advertisements
 

 

 

DMCA.com