Validating date in textbox in asp net define court dating

Posted by / 28-Jun-2020 00:16

To check is string a valid date you can use Compare Validator.

Let say you have one Text Box control on web form, named txt Only Valid Date.

Regular expressions that are already shown here will help you on the client side but you also need to validate these on the server side.

Parse Exact because second one will throw exception if something is not ok.

But yes, you can definitely validate the input i.e the date format.

="^(((((0[1-9])|(1\d)|(2[0-8]))/((0[1-9])|(1[0-2])))|((31/((0[13578])|(1[02])))|((29|30)/((0[1,3-9])|(1[0-2])))))/((20[0-9][0-9]))|((((0[1-9])|(1\d)|(2[0-8]))/((0[1-9])|(1[0-2])))|((31/((0[13578])|(1[02])))|((29|30)/((0[1,3-9])|(1[0-2])))))/((19[0-9][0-9]))|(29/02/20(([02468][048])|([13579][26])))|(29/02/19(([02468][048])|([13579][26]))))$" Hi, It will be difficult to stop the user from changing the date in the textbox.

However, I think your idea is better and more clear.

If I enter 1 January 1000 as the min or max value I get an error saying value cannot be converted to type date, but if I use another format it picks up my entered text as invalid.

Below is my code: I believe that the dates have to be specified in the current culture of the application.

You might want to experiment with setting Culture Invariant Values to true and see if that solves your problem.

Otherwise you may need to change the Date Time Format for the current culture (or the culture itself) to get what you want.

validating date in textbox in asp net-59validating date in textbox in asp net-68validating date in textbox in asp net-38

One thought on “validating date in textbox in asp net”

  1. Symantec Endpoint Protection Manager and Symantec Endpoint Protection Windows client versions do not support the following downgrade paths: Symantec Endpoint Protection 11.0 to 12.1.2 Small Business Edition Symantec Endpoint Protection 12.1.x (enterprise version) to Symantec Endpoint Protection Small Business Edition