Hello,
Can anybody help me please how to check whether the entered date in the maskedTextBox is a valid date/has correct date format?
Thanks in advance.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Feb 28, 2012, 4:34 AM EST
However, as long as 'datp' and 'com' are fields, this should work:
Prime bRank #2,035 · 712 reputationPosted Feb 27, 2012, 6:07 AM EST
Year: YYYY (eg 1997) Year and month: YYYY-MM (eg 1997-07) Complete date: YYYY-MM-DD (eg 1997-07-16) Complete date plus hours and minutes: YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00) Complete date plus hours, minutes and seconds: YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00) Complete date plus hours, minutes, seconds and a decimal fraction of a second YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)VulpesRank #55 · 29.2K reputationPosted Feb 27, 2012, 6:26 AM EST
Check out this MSDN link:
http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.validatingtype.aspx
NelRank #2,060 · 702 reputationPosted Feb 28, 2012, 1:49 AM EST
if (maskedTextBox1.Text != " . .")
{
datp = DateTime.Parse(maskedTextBox1.Text);
com.Parameters.Add("@Data_otstran_rekl", OleDbType.Date).Value = datp;
}
else
{
com.Parameters.AddWithValue("@Data_otstran_rekl", DBNull.Value);
}
but because of the validation, this code can not be executed.
Can you help me please how to achieve this?
Thank you.
VulpesRank #55 · 29.2K reputationPosted Feb 28, 2012, 2:48 AM EST
NelRank #2,060 · 702 reputationPosted Feb 28, 2012, 9:19 PM EST