regex - How to validate a string is in YYYY-MM-DD form (C#) -


most of ways have seen on have involved validating c# date object not want do. i'm working on, user enter string in format example, 1999-02-23. validate string enter follows format of yyyy-mm-dd. solutions have come seem overly complex.

try

var stringtovalidate = "1999-02-23"; datetime dt; bool ok = datetime.tryparseexact(    stringtovalidate,    "yyyy-mm-dd",    cultureinfo.invariantculture,    datetimestyles.none,    out dt ); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -