• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP jQuery表单,带验证具体实现方法_php实例

php 搞代码 3年前 (2022-01-25) 16次浏览 已收录 0个评论

Email检测,密码重复检测,可以用于表单发送的各种环境,例如发送反馈,注册帐号

<div id="container">  <BR>        <?if( isset($_POST['send']) && (!validateName($_POST['name']) || !validateEmail($_POST['email']) || !validatePasswords($_POST['pass1'], $_POST['pass2']) || !validateMessage($_POST['message']) ) ):?>  <BR>                <div id="error">  <BR>                    <ul>  <BR>                        <?if(!validateName($_POST['name'])):?>  <BR>                            <li><strong>Invalid Name:</strong> We want names with more than 3 letters!</li>  <BR>                        <?endif?>  <BR>                        <?if(!validateEmail($_POST['email'])):?>  <BR>                            <li><strong>Invalid E-mail:</strong> Stop cowboy! Type a valid e-mail please :P</li>  <BR>                        <?endif?>  <BR>                        <?if(!validatePasswords($_POST['pass1'], $_POST['pass2'])):?>  <BR>                            <li><strong>Passwords are invalid:</strong> Passwords doesn't match or are invalid!</li>  <BR>                        <?endif?>  <BR>                        <?if(!validateMessage($_POST['message'])):?>  <BR>                            <li><strong>Ivalid message:</strong> Type a message with at least with 10 letters</li>  <BR>                        <?endif?>  <BR>                    </ul>  <BR>                


<?elseif(isset($_POST[‘send’])):?>



  • Congratulations! All fields are OK ;)



<?endif?>





What’s your name?





Valid E-mail please, you will need it to log in!





At least 5 characters: letters, numbers and ‘_’





Confirm password











validation.php

<?php  <BR>    function validateName($name){  <BR>        //if it's NOT valid  <BR>        if(strlen($name) < 4)  <BR>            return false;  <BR>        //if it's valid  <BR>        else  <BR>            return true;  <BR>    }  <BR>    fun<b style="color:transparent">本文来源gao@!dai!ma.com搞$$代^@码!网!</b><strong>搞gaodaima代码</strong>ction validateEmail($email){  <BR>        return ereg("^[a-zA-Z0-9]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$", $email);  <BR>    }  <BR>    function validatePasswords($pass1, $pass2) {  <BR>        //if DOESN'T MATCH  <BR>        if(strpos($pass1, ' ') !== false) <BR>            return false; <BR>        //if are valid <BR>        return $pass1 == $pass2 && strlen($pass1) > 5; <BR>    } <BR>    function validateMessage($message){ <BR>        //if it's NOT valid  <BR>        if(strlen($message) < 10)  <BR>            return false;  <BR>        //if it's valid  <BR>        else  <BR>            return true;  <BR>    }  <BR>?>  <BR>

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP jQuery表单,带验证具体实现方法_php实例

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址