Is there a way to mask text boxes so that they will only accept dates or times?
If not, how can I use a validation webcontrol to ensure that a date or a time was entered into an associated text box?
Printable View
Is there a way to mask text boxes so that they will only accept dates or times?
If not, how can I use a validation webcontrol to ensure that a date or a time was entered into an associated text box?
Hi simon
include the folg code in the head tag
<script language="javascript" src="datetimepicker.js" type="text/javascript">
</script>
include the folg code in the form tag near the texbox
<A href="javascript:NewCal('txtDate','ddmmmyyyy')">
where txtDate holds the value for the date...
best wishes
kindly check the attachment
Hi,
Thanks for your solution.
However, I seem to be having a problem placing the following code:
I place it beneath my text box and every label afterwards becomes a link that pops up the date picker... :confused:Code:<A href="javascript:NewCal('txtDate','ddmmmyyyy')">
Place an </a> after the control you want to make a picker.
Thanks Mendhak.
It seems it only makes labels popup the datepicker. Is that right? Can I make a button do it?
Yes.
In the button's tag, use the onClick="" attribute to call your javascript function that will popup your window for you.
Oh right. Cheers! :thumb:
This is great for inputting dates...
But how do I actually validate that a text box holds a valid date or a valid time (in seperate boxes)?
I know about the IsDate function...but I need to validate dates and times seperately...
Hmm...actually, I'm having problems with this date picker. It returns a date in a format that cannot be parsed by the Date.Parse() function...? :sick:
Show your code and show examples of values that are being returned.
My button that calls the function:
It returns today's date in this format: "22-Apr-2005".Code:<INPUT onclick="javascript:NewCal('txtJobDate','ddmmmyyyy')" type="button" value="...">
My code that retrieves and parses the date from the text box:
My exception details are as follows:VB Code:
Date.Parse(txtJobDate.Text)
"System.FormatException: String was not recognized as a valid DateTime."