Validate textbox with date

1

I have a textbox field that I need to enter the date, I would like to know how I can do when the user is typing, validate the field, and if it is not correct, inform the user. What is the best way to do this validation? And how to do it?

    
asked by anonymous 16.06.2017 / 15:13

1 answer

2

A very simple way for you to do this validation is with JQuery Mask.

Download the plugin here link and in your code you will do the following:

<asp:TextBox runat="server" ID="TxtData" data-mask="00/00/0000" />

Do not forget to initialize the plugin.

You can still create a class with your mask and use it on other parts of the system, like this:

<script>
      $(function(){
          $(".data").mask("00/00/0000", {placeholder: "__/__/____"});
      })
</script>

You can use the placeholder, as declared above to determine in the textbox how the value entered will be entered in the field.

    
04.07.2017 / 14:30