I have a datetime that must required user to key in textbox.Does anyone has idea on checking the datetime that user key in such as IsNumeric?
Printable View
I have a datetime that must required user to key in textbox.Does anyone has idea on checking the datetime that user key in such as IsNumeric?
Have you checked DateTime.TryParse() method? This method will check if the Datetime entered is a valid date/time or not.
Got it ..this is what i do
Code:
Public Function IsDate(ByVal strDate As String) As Boolean
If strDate Is Nothing Then
strDate = ""
End If
If strDate.Length > 0 Then
Dim dteEmpty As Date = Nothing
Return DateTime.TryParse(strDate, dteEmpty)
Else
Return False
End If
Hi,
I have a textbox that required user to key in the date and time together.
I have try with DateTime.TryParse() method .It only return true if the text in the textbox is datetime.
But how if I want to enforce user to key in the date and time together in the textbox(For Example: 13/7/2007 08:00:59.000) .If user key in the date only or time only it will prompt out error message...
Does anyone idea on doing this?
[Merged Threads]
John,
As you already have the similar kind of thread, I have merged them. You can ask questions related to the same issue here also.
Instead of using DateTime.TryParse, use DateTime.TryParseExact.
You can also use MaskedTextBox control.
Got it thanks