gpt4 book ai didi

yii 框架 View 中的 javascript 验证电子邮件

转载 作者:行者123 更新时间:2023-12-03 00:58:31 24 4
gpt4 key购买 nike

<script type="text/javascript">
function validate() {
var email = document.getElementById('email').value;
var phone = document.getElementById('phone').value;

var emailFilter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
var phoneFilter = /^http:\/\//;

if (!emailFilter.test(email)) {
alert('Please enter a valid e-mail address.');
return false;
}

if (!phoneFilter.test(phone)) {
alert('Please correct your phone number.');
return false;
}

return true;
}

</script>

<?php echo $form->textFieldRow($model,'login',array('class'=>'span5','type'=>'email','id'=>'email','maxlength'=>50,'labelOptions' => array('label' => false))); ?>

我在没有运行此 yii 框架的情况下应用了 html 表单但使用 yii 框架时则不然

最佳答案

您可以使用 Yii 表单来实现此目的。

如果你使用 Yii,这将是比在 js 上编写验证更好的解决方案。

您可以看到的示例 here .

关于yii 框架 View 中的 javascript 验证电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52713978/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com