我在JavaScript中的用户端有一个RegExp用于电子邮件检查,如下所示:
var uzorak = new RegExp("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
我想将它重命名为PHP RegExp以进行服务器端检查。
答案 0 :(得分:-1)
$("#Save").click(function(){
var uzorak = new RegExp("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
var EmailAddress = $("#txt1").val();
var uzorak = new RegExp("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
if(!uzorak.test(EmailAddress))
{
alert('not a valid e-mail address');
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" Id="txt1"/>
<button id="Save">Save</button>