转到Html.TextBox()看可以看出

Asp.Net MVC @Html.TextBox 只允许输入数字问题

Html.TextBox()方法,创建文本框【<input type="text"/>】,并且可以带上name,value和html属性;

 看栗子:

 @Html.TextBox("txt", null, new { @class="main"}) 

能生成

<input class="main" >如果是验证输入的类型:邮箱,电话,数字之类的 一是用name 属性JS验证,还可以这么写
验证数字
@Html.TextBox("txtTargetId",null, new {@type="number",@class="styClass"})

就能生成

<input class="styClass" id="txtTargetId" name="txtTargetId" type="number" value="">

验证其他的接着在后面写

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
  • 2021-05-25
  • 2021-11-24
  • 2022-12-23
猜你喜欢
  • 2021-10-01
  • 2022-12-23
  • 2021-05-18
  • 2021-07-22
  • 2022-12-23
相关资源
相似解决方案