Getting Started with Adobe After Effects - Part 6: Motion Blur
A collection of quick technology learning tips from what people around you learn every day

C# - Very easy way to validate user input is valid date or not

Dec 9 2011 11:40PM by Solanki Bhavik A.   

Very easy way to validate user input its valid date

In web application validation is very basic thing when we are working on page where user needs to add input using textbox as user insert correct value Here I display case for valid date you can also do it for integer, double and all

   public static bool IsValidDate(string Date)
        {
            DateTime ValidDate;
            return DateTime.TryParse(Date, out ValidDate);
        }
Read More..   [32134 clicks]

Published under: Microsoft .NET Tips ·  ·  ·  · 


Solanki Bhavik A.
157 · 1% · 310
6
 
5
 
 
0
Incorrect
 
0
Interesting
 
0
Forgotten



Submit

6  Comments  

  • I suggest to provide datetime picker to user instead of giving facility to enter some free text... Its advisable to validate in Client Side itself to prevent additional round-trip.

    However, still this Datetime.TryParse() is pretty much useful...

    commented on Dec 9 2011 12:29PM
    Ramireddy
    2 · 40% · 12972
  • ya that's true my point is that we can use TryParse(datatype,out bool) for check data type is valid or not in many case we have to avoid error for mis data type

    commented on Dec 9 2011 12:52PM
    Solanki Bhavik A.
    157 · 1% · 310
  • I would like to add one more point here. Not only in dotnet framework, this kind of checking is also available in SQL also. In SQL we have ISNUMERIC, ISDATE.

    commented on Dec 11 2011 10:40PM
    naveen0905
    474 · 0% · 81
  • hi, Thanks for comment naveen but what my view is we can use TryParse for any data type for avoid type conversation problem.

    commented on Dec 11 2011 11:23PM
    Solanki Bhavik A.
    157 · 1% · 310
  • Agreed with Bhavik and I find this to be a valuable tip.

    commented on Dec 11 2011 11:34PM
    Jacob Sebastian
    1 · 100% · 32235
  • thanks

    commented on Dec 11 2011 11:36PM
    Solanki Bhavik A.
    157 · 1% · 310

Your Comment


Sign Up or Login to post a comment.

"C# - Very easy way to validate user input is valid date or not" rated 5 out of 5 by 6 readers
C# - Very easy way to validate user input is valid date or not , 5.0 out of 5 based on 6 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]