473,549 Members | 2,627 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validating Date

110 New Member
I want to take the date from user as
MONTHYY ----MAR08,FEB08

how do i do thisalso how i add months to the date (yyyy-mm-dd format and get a new date)



thanks in advance
Mar 5 '08 #1
3 1318
acoder
16,027 Recognized Expert Moderator MVP
For validating that, just have an array of the months ("JAN", "FEB", "MAR", etc.) and check that the first three characters (using substring()) are one of the months. Then check that the last two are digits.

To add months, just use setMonth with the current month (getMonth()) + how many months you want to add.
Mar 5 '08 #2
SSG001
110 New Member
Thanks i did this with pph array for motnhs to give the help to user to select in the format
JAN08 etc
but now i want to check two dates given in this format
say dt1='MAR08'
dt2='JAN10'

I want to check if dt1> dt2 or viceversa
and if it is greater then alert and stop the user to go to the next field

how do i do this in javascript



Thanks
Mar 6 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
You need to use the Date() object. The dates need to be set in a Date object and then comparing is easy. To set the month, use an array of months and loop over until the correct month is found and that would be the number to pass to setMonth(). Use setFullYear() for the year with "20" appended. You could use setFullYear() for both - see this link.
Mar 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

13
3907
by: David Gray | last post by:
Greetings all, Quick newbie type question: I would like to be able to trap non-numerical data entered into a textbox via CTRL+C and/or Shift+Insert. I realise that this data can be validated using the TEXTn_validate event but I would like to stop the user before it gets that far.
6
6313
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334, column 13: there is no attribute "SRC" <bgsound src="C:\My Documents\zingwent.mids"> You have used the attribute named above in your document, but...
5
2369
by: Astra | last post by:
Hi All I have a <SELECT> for the month (1 .. 12) and a <SELECT> for the year (2004 .... 2020), do you know of any js validation check I can use to check whether these values are older than today's date so that I can bring up a warning, eg user chooses 04 and 2003 or 01 and 2004 OnClick a validate script sees that either of the above...
5
5979
by: Steve | last post by:
I am currently trying to validate data in an access database. I need to verify that columns containing date information are in the format ddmmyyyy and columns containg time information are in the format HH:MM 24. The dates and times are stored in text fields. ie date 12121998, time 20:34 Could anyone suggest a method for validating the...
1
2885
by: panche | last post by:
I'm developing a fairly simple user control that has two textboxes for date/time entry (a from date/time and a to date/time). One of my requirements is that there should be no button that sets these values (i.e., no button to cause a postback). The problem I'm having is that I need a number of validations to be performed on the data entry,...
1
4190
by: viki.sanjeeva | last post by:
Hi, There is a date field in JSP form where user will enter date in dd-mm-yyyy format. Now before saving into DB2, I want to validate the date format against dd-mm-yyyy format and then save into DB2. I've tried reading SimpeDateFormat and other date format classes, but couldn't understand. It will be great if somebody tell the following...
21
9137
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on the cancel button, the textbox.validating is being called. I don't want it to be since they are exiting the screen the validation doesn't have to be...
1
1297
by: lenin42001 | last post by:
Help i've just done a basic calculator with three textboxes a label & a button, basically when you add a number in textbox1 to the one in textbox2 it appears in textbox3 .........now the question asks to check if the user has typed in something appropriate . It says double click on txtnum1 use right hand list box to find Validating( ) event, then...
1
1530
by: =?Utf-8?B?Ym9iYnk=?= | last post by:
I have a textBox Where I type date. I want to validate it. Im using customValidate controls. I have this function in my code behind page void DatesValidate(object source, ServerValidateEventArgs e) { if (Convert.ToDateTime(e.Value) <= DateTime.Now) { e.IsValid = false; this.lblAddUsers.Text = "The Proxy is already expired"; }
6
4492
by: Richard | last post by:
I'm validating a date and time string which must be EXACTLY of the format yy-mm-dd hh:mm:ss and extracting the six numeric values using sscanf. I'm using the format string "%2u-%2u-%2u %2u:%2u:%2u" which works, but it allows each numeric field to be either 1 or 2 digits in length. Also the man page for sscanf says that preceeding white...
0
7521
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7451
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7959
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7473
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7810
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5369
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
764
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.