如何在MVC中的文本框中添加数字验证 [英] How to add numeric validation on text box in MVC

查看:78
本文介绍了如何在MVC中的文本框中添加数字验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何限制用户输入字符串值,只允许整数或小数



我尝试过:



@ Html.TextBox(InvoiceNo,,new {@class =form-control,placeholder =####,id =InvoiceNo})

@ Html.ValidationMessage(InvoiceNo)

how to restrict user to enter string values, only allow interger or decimals

What I have tried:

@Html.TextBox("InvoiceNo", "", new { @class = "form-control", placeholder = "####", id = "InvoiceNo" })
@Html.ValidationMessage("InvoiceNo")

推荐答案

@ Html.TextBox(InvoiceNo,,new {@class =form-control,占位符=####,id =InvoiceNo,type =number})
@Html.TextBox("InvoiceNo", "", new { @class = "form-control", placeholder = "####", id = "InvoiceNo", type = "number" })


这篇关于如何在MVC中的文本框中添加数字验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆