首页 \ 问答 \ Jquery验证数字范围(Jquery validate number range)

Jquery验证数字范围(Jquery validate number range)

我想在jquery验证规则中将有效数字从-1设置为无穷大,但是我应该如何指定数字范围。 我指定的“-1”和它的工作,但在什么应该是值。

rules: {
                "numberOfUsers": {
                    "required": true,
                    "number":true,
                    "range":[-1,1000]
                }

- 谢谢


I want to set the valid number from -1 to infinity in the jquery validate rules, but how should i specify the number range. In from i specified "-1" and its working but in to what should be the value.

rules: {
                "numberOfUsers": {
                    "required": true,
                    "number":true,
                    "range":[-1,1000]
                }

-- Thanks


原文:https://stackoverflow.com/questions/13797838
更新时间:2023-10-20 22:10

最满意答案

您可以使用:

if (preg_match('/\$\D*(\d+(?:,\d+)*)/', $input, $matches)) {
   echo $matches[1] . "\n"; // 10,00
}

RegEx演示


You can use:

if (preg_match('/\$\D*(\d+(?:,\d+)*)/', $input, $matches)) {
   echo $matches[1] . "\n"; // 10,00
}

RegEx Demo

相关问答

更多
  • 我已经看到这两种方式。 所有你正在做的是创建一个名为'$ selector'的变量,所以它们在功能上是等效的。 关于它的好处是它确实可以让他们轻松选择jQuery对象。 I've seen it done both ways. All you are doing is creating a variable with the name '$selector', so they are functionally equivalent. The nice thing about it is that it do ...
  • 1)美元符号未分配,几年前还是我记得错了吗? 这是正确的,仍然是真的。 2)什么是美元符号,如果不是jQuery? Firefox和Chrome实现$ , $$和其他几个作为助手命令。 两者都将将$$设置为document.querySelectorAll() ,并将$设置$ document.querySelector如果window.$尚未定义。 所以你看到的并不是标准的JavaScript,而是浏览器的开发者控制台的帮手。 它也不是jQuery(只要你不在使用jQuery的页面上)。 但是,它的行为接 ...
  • 是的,这是一个字符串。 它将简单地附加到massConvoMsg的末尾,并且处理的组合事物是单个字符串。 Yes, that is a string. It will simply be appended to the end of massConvoMsg and the combined thing treated is single string.
  • 使用双美元内的任何字符串来区分它: select $anything$abc$$anything$; ?column? ---------- abc$ insert是相似的: insert into t (a, b) values ($anything$abc$$anything$, $xyz$abc$$xyz$); INSERT 0 1 select * from t; a | b ------+------ abc$ | abc$ Use any string inside ...
  • 如果您的目的是仅更改具有该特定目录的路径,则需要更加棘手。 你必须在没有尾随/的行的末尾捕获它,并且你还必须在它具有尾随/ (行尾或不行)的任何地方捕获它。 但是你不想捕获像/var/lib/mysqlplus这样的/var/lib/mysqlplus因为那是一个完全不同的目录。 考虑使用扩展正则表达式,并使用不同的分隔符,因此命令看起来不像锯齿( /\/\/\/\/\/\/\/\ )。 通过这些更改,以及对正则表达式本身的一个小修改,它可以正常工作: $ echo ' /var/lib/mysqlplus ...
  • 是。 在你的情况下,你真的想要使用window的load事件,你可以简单地在你的事件处理程序中使用一个局部变量: jQuery(window).bind("load", function() { var $ = jQuery; // Use $ here... }); 或者你可以使用内联调用的函数: (function($) { // Use $ here... $(window).bind("load", function() { // Page is ...
  • 你可以做的一种方法是使用pipe | (替代运营商): ^(\$\d{1,3}|\d{1,3}\$)$ 请参阅DEMO One of the ways you can do is using pipe | (alternative operator): ^(\$\d{1,3}|\d{1,3}\$)$ See DEMO
  • 您可以使用replace将$字符replace为空字符串: var price = $("div").text().replace("$", ""); 请注意,在您的确切示例(使用该间距)的情况下,空格不会被删除。 如果你打算使用字符串作为数字(例如通过parseFloat ),但是如果你想将它用作其他地方的文本,你可能想用jQuery的.trim 。 更新 - 基于评论 replace返回一个字符串。 一旦你有了这个字符串,你可以用parseFloat (或parseInt ,但你正在处理浮点数)将它解 ...
  • 您可以使用: if (preg_match('/\$\D*(\d+(?:,\d+)*)/', $input, $matches)) { echo $matches[1] . "\n"; // 10,00 } RegEx演示 You can use: if (preg_match('/\$\D*(\d+(?:,\d+)*)/', $input, $matches)) { echo $matches[1] . "\n"; // 10,00 } RegEx Demo
  • 给出的查询将选择concept_description包含$的行,但我假设您想要实际提取美元金额? 如果一个字段中只有一美元金额,则可以使用它来提取 SELECT SUBSTRING( concept_description, LOCATE('$', concept_description), LOCATE(' ', concept_description, LOCATE('$', concept_description)) - LOCATE('$', concept_descrip ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)