设为首页 - 加入收藏
广告 1000x90
您的当前位置:主页 > 建站教程 > 正文

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

来源:建站教学网 编辑:小编 时间:2019-10-09 12:36
PHP jQuery表单,带验证具体实现方法

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

复制代码 代码如下:
<div> 
        <?if( isset($_POST['send']) && (!validateName($_POST['name']) || !validateEmail($_POST['email']) || !validatePasswords($_POST['pass1'], $_POST['pass2']) || !validateMessage($_POST['message']) ) ):?> 
                <div> 
                    <ul> 
                        <?if(!validateName($_POST['name'])):?> 
                            <li><strong>Invalid Name:</strong> We want names with more than 3 letters!</li> 
                        <?endif?> 
                        <?if(!validateEmail($_POST['email'])):?> 
                            <li><strong>Invalid E-mail:</strong> Stop cowboy! Type a valid e-mail please :P</li> 
                        <?endif?> 
                        <?if(!validatePasswords($_POST['pass1'], $_POST['pass2'])):?> 
                            <li><strong>Passwords are invalid:</strong> Passwords doesn't match or are invalid!</li> 
                        <?endif?> 
                        <?if(!validateMessage($_POST['message'])):?> 
                            <li><strong>Ivalid message:</strong> Type a message with at least with 10 letters</li> 
                        <?endif?> 
                    </ul> 
                </div> 
            <?elseif(isset($_POST['send'])):?> 
                <div> 
                    <ul> 
                        <li><strong>Congratulations!</strong> All fields are OK ;)</li> 
                    </ul> 
                </div> 
        <?endif?> 

        <form method="post" action=""> 
            <div> 
                <label for="name">Name</label> 
                <input type="text" /> 
                <span>What's your name?</span> 
            </div> 
            <div> 
                <label for="email">E-mail</label> 
                <input type="text" /> 
                <span>Valid E-mail please, you will need it to log in!</span> 
            </div> 
            <div> 
                <label for="pass1">Password</label> 
                <input type="password" /> 
                <span>At least 5 characters: letters, numbers and '_'</span> 
            </div> 
            <div> 
                <label for="pass2">Confirm Password</label> 
                <input type="password" /> 
                <span>Confirm password</span> 
            </div> 
            <div> 
                <label for="message">Message</label> 
                <textarea cols="" rows=""></textarea> 
            </div> 
            <div> 
                <input type="submit" value="Send" /> 
            </div> 
        </form> 
    </div> 

validation.php


    本文网址:http://www.shlzwl.cn/a/jianzhan/2019/1009/68369.html ,喜欢请注明来源。

上一篇:php实现mysql数据库操作类分享
下一篇:没有了

网友评论:

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
PHP jQuery表单,带验证具体实现方法

站长沙龙 www.shlzwl.cn 中国百万站长的福音,一站式服务。网站地图

Copyright © 2002-2019 站长沙龙 客服qq:2501324206

Top