jQuery正则表达式测试(jQuery regex test)
我正在尝试验证正则表达式的值,以检查该数字是否为小数(小数点后仅2位)/整数。 其余的应该是无效的。
我在这里使用了建议的正则表达式: 一个十进制的简单正则表达式,精度为2
但是当我将它包含在我的jquery正则表达式函数中时,它似乎不起作用:
function checkRegexp( o, regexp, n ) { if ( !( regexp.test( o.val() ) ) ) { o.addClass( "ui-state-error" ); updateTips( n ); return false; } else { return true; } } bValid = bValid && checkRegexp( o_buy, /\d+(\.\d{1,2})?/, "Buy field can only contain numbers, no currency please" );
我究竟做错了什么?
谢谢,
I'm trying to validate a value against a regex to check if the number is either a decimal (with only 2 digits after the decimal point)/integer. The rest should be invalid.
I used the suggested regex here: Simple regular expression for a decimal with a precision of 2
But when I included it in my jquery regex function, it doesn't seem to work:
function checkRegexp( o, regexp, n ) { if ( !( regexp.test( o.val() ) ) ) { o.addClass( "ui-state-error" ); updateTips( n ); return false; } else { return true; } } bValid = bValid && checkRegexp( o_buy, /\d+(\.\d{1,2})?/, "Buy field can only contain numbers, no currency please" );
What am I doing wrong?
Thanks,
原文:https://stackoverflow.com/questions/5126408
更新时间:2021-09-05 13:09
最满意答案
试试这个xapths
//div[@class='tabHeader']
要么
//div[@class='tabHeader'][contains(text(),'SER20170905111755')]
Try this xapths
//div[@class='tabHeader']
or
//div[@class='tabHeader'][contains(text(),'SER20170905111755')]
相关问答
更多-
LINUX 如何查看JPG文件[2022-06-13]
find -
Python Selenium:找不到costar.com的登录元素(Python Selenium: Can't find the login element of costar.com)[2021-11-22]
要使用Selenium将文本输入到输入框中(例如,将您的用户名输入用户名字段),请使用元素的send_keys方法: input_element.send_keys('some_text_string') 您也可以尝试使用Selenium的action_chains模块,如下面的代码(未经测试),从@ dm295的答案中找到障碍: from selenium import webdriver from selenium.webdriver.common import action_chains driv ... -
在xpath下面使用以排除第一行(标题) //table[@id='ctl00_MasterPlaceHolder_GrdHistory']/tbody/tr[position()>1] Use below xpath to exclude first row (Headers) //table[@id='ctl00_MasterPlaceHolder_GrdHistory']/tbody/tr[position()>1]
-
使用requests库来发出HTTP请求,它比Python内置的要好得多,原因有很多。 它自动和智能地处理编码。 import requests response = requests.get('https://www.ss.lv/msg/ru/real-estate/flats/riga/plyavnieki/onlol.html') page = BeautifulSoup(response.text, 'html.parser') Use the requests library for makin ...
-
storeEval可以帮助你! 在selenium IDE中运行它作为你的源代码。尝试 (?
Selenium迭代中的StaleElementReferenceException(StaleElementReferenceException in iteration with Selenium)[2023-11-29]
staleElementReferenceException由循环迭代之前收集的行列表引起。 最初,您创建了名为table_rows的所有行的列表。 table_rows = driver.find_elements_by_tag_name('tr') 现在在循环中,在第一次迭代期间,第一行元素是新鲜的,并且可以由驱动程序找到。 在第一次迭代结束时,您正在执行driver.back() ,您的页面将更改/刷新HTML DOM。 以前收集的所有参考文献都已丢失。 您的table_rows列表中的所有行现在 ...试试这个xapths //div[@class='tabHeader'] 要么 //div[@class='tabHeader'][contains(text(),'SER20170905111755')] Try this xapths //div[@class='tabHeader'] or //div[@class='tabHeader'][contains(text(),'SER20170905111755')]在字符串中查找确切的单词(Find an exact word in a string)[2021-11-13]
没有一个简单的方法。 你有三个选择 运行您的查询,然后在客户端上进行模式匹配 使用SQL全文搜索引擎 将CLR函数添加到数据库,以便进行正则表达式匹配 There isn't an easy way. You have three options run your query, then do the pattern matching on the client use SQL Fulltext Search engine add a CLR function to the database that le ...首先,xpath函数text()必须用小写编写。 您正在寻找的链接条目也不是第三个(3)div。 因为直接下载是div中带有class =“right”的链接。 请试试这个: "//div[div/a[text()='Firefox 22.0 (Beta 2)']]/div[@class='right']/a" First of all the xpath function text() has to written in lowercase. Also the link entry you are lo ...相关文章
更多- JAVA 正则表达式教程(超详细)三(续)
- JAVA 正则表达式教程(超详细)二(续)
- Java正则表达式
- 关于正则表达式空格的问题.
- 揭开正则表达式的神秘面纱
- 请问匹配这种格式的正则表达式怎么写?
- java 中一个简单的正则表达式问题,帮忙看下.
- JAVA 正则表达式教程(超详细)一
- 怎样用正则表达式怎么从字符串“123_DT1_AddButton”中截取123
- Hadoop 0.21如何运行单个test case
最新问答
更多- 您如何使用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)