在我的页面中,我有 5 个TextBoxes
和 1 个DropDownlist
盒子
- 名称(它应该只允许字母)
- 用户名(它应该允许字母和数字)
- EmailID(电子邮件格式)
- 电话号码(仅限整数
- 性别
- 密码(字母和数字的组合)
上述内容应在键入时进行验证,如果格式正确,则应显示刻度图像.....
如果我们在不输入数据的情况下按 Tab,则错误消息应显示在TextBox
请帮助我...
我对 mvc3 比较陌生。
Below is the code i have created. Now I need to validate.... please tell me how to do it
<table>
<tr>
<td> @Html.Label("FirstdName")</td>
<td> @Html.TextBox("FirstName")</td>
<td> @Html.ValidationMessageFor(x => x.FirstName)</td>
</tr>
<tr>
<td> @Html.Label("Username")</td>
<td> @Html.TextBox("Username")</td>
<td> @Html.ValidationMessageFor(x => x.Username)</td>
</tr>
<tr>
<td> @Html.Label("Password")</td>
<td> @Html.TextBox("Password")</td>
<td> @Html.ValidationMessageFor(x => x.Password)</td>
</tr>
<tr>
<td> @Html.Label("ConfirmPassword")</td>
<td> @Html.TextBox("ConfirmPassword")</td>
<td> @Html.ValidationMessageFor(x => x.ConfirmPassword)</td>
</tr>
<tr>
<td> @Html.Label("Phone")</td>
<td> @Html.TextBox("Phone")</td>
<td> @Html.ValidationMessageFor(x => x.Phone)</td>
</tr>
<tr>
<td> @Html.Label("Gender")</td>
<td> @Html.DropDownListFor(Per => Per.Gender, new[]{
new SelectListItem(){Text="Male",Value="Male"},
new SelectListItem(){Text="Female",Value="Female"},
}, "--Select--")</td>
<td> @Html.ValidationMessageFor(x => x.Gender)</td>
</tr>
<tr>
<td> @Html.Label("Email")</td>
<td> @Html.TextBox("Email")</td>
<td> @Html.ValidationMessageFor(x => x.Email)</td>
</tr>
</table>
<input type="submit" value="Ok" />
</form>