文本输入中的最小最大数量 - Jquery/javascript

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4858949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 15:07:54  来源:igfitidea点击:

min max number in text input - Jquery/javascript

javascriptjqueryinputnumbersrange

提问by Tommy Arnold

I would like to set a minimum and maximum allowed number to be entered in text input I know I can do this with range input but will it still have the max and min when used in non compatible browsers?

我想设置在文本输入中输入的最小和最大允许数字我知道我可以使用范围输入来做到这一点,但是在不兼容的浏览器中使用时它仍然具有最大值和最小值吗?

if not could you please point me in the right direction, thanks for reading.

如果没有,请您指出正确的方向,感谢您的阅读。

回答by gor

Use jquery validator plugin. It has a nice set of features, and min max validation too. But checking values on server side is a must too. Hereis an examples for minand max.

使用jquery 验证器插件。它有一组很好的功能,也有最小最大验证。但是检查服务器端的值也是必须的。minmax的示例。

回答by icktoofay

No; you can never rely on the client. Always check on the server side as well.

不; 你永远不能依赖客户。始终检查服务器端。

回答by futuremint

I've had success with the jQuery h5Validateplugin. Its pretty simple in what it aims to accomplish (which is exactly what you want here).

我使用 jQuery h5Validate插件取得了成功。它的目标非常简单(这正是您在这里想要的)。

Also, validate it on the server side too.

此外,还要在服务器端对其进行验证。