I have registration form and its contain date of birth field.
Using calender date picker its input the value to this field.
these are the steps to insert value for this field
step 1
step 2
step 3
so its taking values in dd/MM/yyyy format
This is appearance of date of birth field in my model class
[DisplayName("Date of Birth")]
[DataType(DataType.Date), DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public Nullable<System.DateTime> Date_of_Birth { get; set; }
This is appearance of date of birth field in my view file
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(model => model.Date_of_Birth)
@Html.Label("*", new { id="star" , @class = "requiredFiledCol" })
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Date_of_Birth, "{0:dd/MM/yyyy}", new { @class = "form-control datepicker", placeholder = "DD/MM/YYYY" , maxlength="100" })
@Html.ValidationMessageFor(model => model.Date_of_Birth)
</div>
</div>
I want to do client side validation for data of birth field . show error message when input filed is not in this range 100>Age>18
whats the approach I should take ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…