1

I am Using textbox for input date user.
How to auto masking when user input value date with format mask "dd-MM-yyyy"

Thanks

1

3 Answers 3

1

I'm not sure I understand your question, but you can use an ASP.NET CompareValidator to ensure the input is a valid date:

<asp:CompareValidator 
    id="cv_date" runat="server"  
    Type="Date" 
    Operator="DataTypeCheck" 
    ControlToValidate="tb_my_textbox"  
    ErrorMessage="Please enter a valid date."> 
</asp:CompareValidator> 
Sign up to request clarification or add additional context in comments.

2 Comments

No this will ensure the text that's entered is a valid date. Using this, you could then format the values entered in your codebehind using DateTime.ToString("dd-MM-yyyy");
i'm using two language for my web. exist problem with this validator when switch to local language with other format date where i have format default for that for textbox is "dd/MM/yyyy". Tanks
1

You can't do that with the standard asp.net controls. You might try ajax control toollkit, which is a set of ajax controls. You can find out about it here: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/MaskedEdit/MaskedEdit.aspx

Or you could build your own masking using javascript.

2 Comments

I'm not using ajax, i'm use textbox wit jquery datetimepicker.
You can write a custom function in jquery or javascript. Here is an example in another post:stackoverflow.com/questions/480979/…
1

you can try following JScript:

$(document).ready(
  function() {
   $('#txtbx').click(
     function() {
         $("#txtbx").mask("999-99-9999");
        });
  });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.