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




Have Programming Question? Ask it here!
 
 
 


arpita rajan patel
date function
1 Answer(s)      3 years and 5 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
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
function
function  difference between function overloading and operator overloading
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
date
date   how to insert date in database? i need coding
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
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
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
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_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  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
DATE
DATE  I have the following as my known parameter Effective Date... of calcultion starts My question is how to find the date of Thursday This cycle... the date of all the thursdays of the given year. import java.util.*; import
date_sunrise
  date_sunrise date_sunrise function returns time of sunrise for a given day and location.  Description on PHP Date Sunrise Function mixed date_sunrise ( int $timestamp [, int $format= SUNFUNCS_RET_STRING [, float
PHP Date and Time
PHP Date and Time The PHP Date and Time function is massively used in setting date and time of the server, validating date and time and controlling the functions of the software.  The PHP date and Time functions allow you
Check Date in PHP
Check Date in PHP The Checkdate() The PHP Checkdate function is used for validating the system date. It validate the Gregorian date. It returns 'True' if finds the specified date valid, otherwise it returns false. Note
date_timestamp_get
date_timestamp_get date_timestamp_get alias DateTime::getTimestamp function is used for getting the Unix timestamp.  Syntax public int DateTime::getTimestamp ( void ) Parameters This function has no parameters
date_time_set
date_time_set date_time_set alias DateTime::setTime function resets... the modified date and time.  Syntax public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] ) DateTime date_time_set ( DateTime $object
NSLog Date example code
and then used the NSLog function to print the date on the console. // // ...{     today= [NSDate date];     NSLog(@"the current date is %@",today); } @end  
date_sun_info
  date_sun_info() Function of PHP date_sun_info function returns...() Function array date_sun_info ( int $time , float $latitude , float $longitude... Info Function in PHP <?php $sun_info = date_sun_info(strtotime("
date_sunset
date_sunset() in PHP date_sunset function returns the sunset time... time in a specified format on success, or FALSE on failure. Syntax of date_sunset() in PHP mixed date_sunset ( int $timestamp [, int $format= SUNFUNCS_RET
date_isodate_setdate
date_isodate_setdate The ISO Date Format PHP or DateTime::setISODate function sets the date according to ISO 8601 standard - using weeks and day offsets... of ISO Date Format in PHP public DateTime DateTime::setISODate ( int $year, int
date_timezone_set
date_timezone_set() in PHP date_timezone_set alias DateTime::setTimezone function is used for setting the time zone for the DateTime object. It returns the modified DateTime.  Syntax on date_timezone_set() PHP public
date_timezone_get
PHP Date Timzezone Get The date_timezone_get alias DateTime::getTimezone function returns time zone relative to given DateTime. It returns DateTimeZone object on success or FALSE on failure. Syntax of date_timezone_get() in php
isNaN function
isNaN function  What does isNaN function do
date format - Date Calendar
date format  how to convert dd-mmm-yyyy date format to gregorian... to convert date to calender. import java.util.*; import java.text.*; public...="19-Sep-2008"; DateFormat format ; Date date ; format = new
function addValue
function addValue  i have question about the javascript the function addvalue script is working to add some name but is not save on the html so please resolve my problem what can i do for addvalue function will be to save
function addValue
function addValue  i have question about the javascript the function addvalue script is working to add some name but is not save on the html so please resolve my problem what can i do for addvalue function will be to save
function addValue
function addValue  i have question about the javascript the function addvalue script is working to add some name but is not save on the html so please resolve my problem what can i do for addvalue function will be to save
using function
using function   using a function to find the value of v from the foiiowing expression 1v=1u+1*f
function method
function method  input Rs. 12000 Discount= 10%, 8% = Rs.(12000-1200) = Rs.(10800-864) = Rs. 9936
 

 

 

DMCA.com