Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Cypress中使用RegExp验证电话号码?_Javascript_Regex_String_Cypress - Fatal编程技术网

Javascript 如何在Cypress中使用RegExp验证电话号码?

Javascript 如何在Cypress中使用RegExp验证电话号码?,javascript,regex,string,cypress,Javascript,Regex,String,Cypress,我正在尝试在Cypress中验证我的电话号码以匹配我的regExp。我如何解决这个问题 尝试1 上述代码显示此错误: 尝试2 上述代码显示此错误: 提取代码工作所需的值 cy.get('#FormField_7_input') .invoke('val') .should('match', /^\d{2}([ .-]?)\d{2}(?:\1\d{2}){3}$/gmu) 再次感谢。看起来您正在获取输入元素,您需要从中提取值。 cy.get('#FormField_7_input')

我正在尝试在Cypress中验证我的电话号码以匹配我的regExp。我如何解决这个问题

尝试1 上述代码显示此错误:

尝试2 上述代码显示此错误:


提取代码工作所需的值

cy.get('#FormField_7_input')
.invoke('val')
.should('match', /^\d{2}([ .-]?)\d{2}(?:\1\d{2}){3}$/gmu)

再次感谢。

看起来您正在获取输入元素,您需要从中提取值。
cy.get('#FormField_7_input')
    .should('match', /^\d{2}([ .-]?)\d{2}(?:\1\d{2}){3}$/gmu)
cy.get('#FormField_7_input')
.invoke('val')
.should('match', /^\d{2}([ .-]?)\d{2}(?:\1\d{2}){3}$/gmu)