0

Textbox having date field

I have a textbox field called "Expires on" and I am using DatePicker

 $("#sfExpiresOn").datepicker({
                    dateFormat: "yy-mm-dd",
                    changeMonth: true,
                    changeYear: true,
                    minDate: 0
                })

Here, I need validation because use can simply add random number here like

enter image description here

How can i prevent user to add random number values. (I don't need HTML 5 validation.)

Thank You

2
  • If you would like to use a plugin, check here Commented Mar 14, 2014 at 6:20
  • U can use maskedEditExtender of ajax.... that will allow to inset text but only that text which is acceptable according to format Commented Mar 14, 2014 at 6:22

2 Answers 2

1

Why don't you add the property

ReadOnly="true"

to your textbox?

Simply, add the following code to your script

$("#sfExpiresOn").attr( 'readOnly' , 'true' );
Sign up to request clarification or add additional context in comments.

1 Comment

Glad to help :) Please accept my answer if you wish to.
0

If u don't want to use ReadOnly feature the u can use MaskedEditExtender of AJAX. Lets say if i want my calender date to be like DD/MM/YYY then it will be like this

<Ajax:MaskedEditExtender ID="MaskedEditExtender3" TargetControlID="txtdate"
   Mask="99/99/9999" MessageValidatorTip="true" OnFocusCssClass="MaskedEditFocus"
   OnInvalidCssClass="MaskedEditError" MaskType="Date" 
   UserDateFormat="DayMonthYear"
   DisplayMoney="Left" AcceptNegative="Left" ErrorTooltipEnabled="True" 
   runat="server">

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.