簡體   English   中英

在javascript中使用服務器端正則表達式

[英]using serverside regular expression in javascript

我正在通過編寫服務器端正則表達式驗證網站,當我復制它時
的東西,並嘗試驗證其沒有發生我的代碼的一部分如下

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

我如何在客戶端驗證中實現相同的功能

String.match考慮將正則表達式視為String而不是RegExp對象。 嘗試這個:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM