开发者

using serverside regular expression in javascript

开发者 https://www.devze.com 2023-02-02 06:04 出处:网络
I am validating website by writing serverside regular expression when i copy the same thing in javascript and try to validate its not happening a part of my c开发者_高级运维ode is as follows

I am validating website by writing serverside regular expression when i copy the same

thing in javascript and try to validate its not happening a part of my c开发者_高级运维ode is as follows

"^(https://)+\w+\.+\w" - //serverside validation working fine
document.getElementById('txtWebsite').value.match("^(https://)+\w+\.+\w") == null

how can i implement the same in client side validation


String.match is considering you regex as String and not as a RegExp object. Try this:

document.getElementById('txtWebsite').value.match(/^(https:\/\/)+\w+\.+\w/)
0

精彩评论

暂无评论...
验证码 换一张
取 消