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



Home Answers Viewqa Development-process Validating date in javascirpt
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Rajendra
Validating date in javascirpt
1 Answer(s)      5 years and 10 months ago
Posted in : Development process



Advertisement
View Answers

February 26, 2009 at 6:40 AM


Hi,

The following code may be useful for u.

<input type="text" id="usrdate" value=""/>

jscode:

var usrdate = document.getElementById("usrdate").value;//get user entered date
var usrdateArr = usrdate.split("--");//split the date by using '--' as token
var date = usrdateArr[0];//get date
var month = usrdateArr[1];//get month
var year = usrdateArr[2];//get year

//below if cond., is using to check the date is valid or not based on month
if((month == 1) || (month == 3) || (month == 5) || (month == 7) || (month == 8) || (month == 10) || (month == 12)){
if(date<=0 && date>31){
alert("invalid date");
}
}else if(month == 2 && date<=0 && date>28){
alert("invalid date");
}else if(date<=0 && date>30){
alert("invalid date");
}

//below if cond., is using to check the month is correct or not
if(month<1 || month>12){
alert("invalid month");
}

//here year should not be less than 1.
if(year<1){
alert("invalid date");
}


regards,
siva kumar


Related Tutorials/Questions & Answers:
Validating date in javascirpt - Development process
Validating date in javascirpt   Hi Friends, Can u plz give sample code for validating date in javascript using textbox.((dd--mm--yyyy...;//get user entered date var usrdateArr = usrdate.split("--");//split the date
Validating date in javascript - Java Interview Questions
Validating date in javascript   Hi Deepak, Can u give 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
Advertisements
Javascirpt Programing
Javascirpt Programing  write a html page with javascript to check a number is prime or not.   Hi Friend, Try the following code: <script type="text/javascript"> function check(){ var num
validating a HTML
validating a HTML  What are the reasons for validating a HTML
Validating XML
Validating XML  Hi, I have a string containing data in XML format. I have to Validate this xml data. Is there any method in java that allows strings as input to validate xml?   Please visit the following link: http
validating web pages
validating web pages  How to validate HTML web pages
Validating image size
Validating image size  How to validate image size to 2MB in javascript which is updating to mysql database
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
validating a form before data is entered.
validating a form before data is entered.  How can I avoid validating a form before data is entered
validating - Swing AWT
validating   hi another problem i am facing in swing is that is i have got many textfeilds ex: Roll No: Name: Address: so Roll No TextField have to Contains only Numbers. Name TextFields have to contain only
validating email id
validating email id  how to validate the email id ?   <html> <script> function validate(){ var e=document.getElementById('email').value; var regExpObj = /(\d\d\d)-\d\d\d\d\d\d\d\d/; var reg
Validating the password field
Validating the password field  When the validate method returns back to the registration page the password field get cleared there by asking again one more time to enter the password field at the time of re-submitting the form
Date validation in JSP
Date validation in JSP       Example for validating date in a specified format in a JSP page This example illustrates... JavaScript for validating date in a specified format as "MM/DD/YYYY". We
validating username and password from database
validating username and password from database  Hello sir, i am developing a login page. i want that when i fill data in text fields. it validate data from database. if enter data is match from database. page goes to next page
validating text fields - Swing AWT
validating text fields  hi i am using NETBEANS IDE so when i want to validate TEXTFEILDS if one textfield is blank then it should focus on that particular textfield so help me with this plz..... /* * To change this template
date
date   how to insert date in database? i need coding
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
Validating Duplicate Entry To Database - Java Beginners
Validating Duplicate Entry To Database  I have a servlet that adds data to the table called foodtype in (Ms Access). i already have Chinese, vegetarian entered in table. what am trying to do is to validate when entering foodtypes
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
Validating Number Very Urgent - JSP-Servlet
Validating Number Very Urgent  Respected Sir/Madam, I am R.Ragavendran.. I want u to insert the coding for validating number in the place of Emp ID text box.. I am sending the code for your kind reference which tends you
date
database table name birthday (DOB date); dob with DATE data type in database while...=d.getTime(); java.sql.Date date = new java.sql.Date(t); try { System.out.println(date); Class.forName("oracle.jdbc.OracleDriver"); con
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
Interview question - Date Calendar
Interview question   Hi Friends, can u give me sample code for validating date. Thank u
Validating Emp ID Reply - JSP-Servlet
Validating Emp ID Reply  Respected Sir/Madam, I am Ragavendran.R.. Thanks for your quick response.. Actually I need to check whether Emp ID contains any Special characters and Alphabets..If yes,It must display "Please Enter
validating credentials and displaying error message in login .jsp if not valid
validating credentials and displaying error message in login .jsp if not valid  hi, i want to validate user name and password against my database table if not valid i have to display error message in my login page.how to do
 

 

 

DMCA.com