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?
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?
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.