• JS 多邮件验证


    1、前端JS代码
    /*      receiver-----接收人   */
    function foreachEmail(receiver){
            var str="";
            var email ="";
            if(receiver!="" && receiver.indexOf(";")>0)
            {
                var arremail=receiver.split(";");
                for(var i=0;i <arremail.length;i++)
                {
                    if(arremail[i].replace(/s+/g,"").search(/^w+((-w+)|(.w+))*@[A-Za-z0-9]+((.|-)[A-Za-z0-9]+)*.[A-Za-z0-9]+$/)==-1)
                    {
                        str=str+arremail[i]+"格式错误! ";
                    }else{
                        if(i > 0){
                            if(arremail[i] != arremail[i-1]){
                                email = email+";"+arremail[i];
                            }
                        }else{
                            email = arremail[i];
                        }
                    }
                }
                receiver = email;
            }else{
                if(receiver.replace(/s+/g,"").search(/^w+((-w+)|(.w+))*@[A-Za-z0-9]+((.|-)[A-Za-z0-9]+)*.[A-Za-z0-9]+$/)==-1)
                {
                    str=receiver+"格式错误! ";
                }
            }
            if(str!="")
            {
                $("#alertmsg").html(str);
                return false;
            }
            return receiver;
        }
    //当文本框失去焦点时,判断是否输入重复的邮箱输入的话就不显示重复的邮箱
    $("#receiver").blur(function(){
            var email = foreachEmail($("#receiver").val().replace(/(^s*)|(s*$)/g,''));
            if(email == false){
                $("#receiver").val("");
            }else{
                $("#receiver").val(email);
            }
     });
    function sendEmail(){
        receiver = $("#receiver").val();
        receiver  = foreachEmail(receiver);
        if(receiver   == false){
            return false;
        }
        $.ajax({
            ...                                                                                     //此处略去发送的代码
        });
    }
    2、后台PHP代码
        可以用explode()方法把取得的邮件字符串分离,代码就不赘述了!!!

  • 相关阅读:
    BUUOJ | [ACTF新生赛2020]usualCrypt (多重加密)
    高数笔记 | 快速索引 + 期末总结(2019-2020学年第二学期)
    BUUOJ | SimpleRev(字符对称加密)
    CTF OJ 题目分类 | Reverse
    CPPU程序设计训练营清明天梯模拟赛题解
    数据可视化 | 2020年3月世界疫情实存人数地图
    CTF OJ 题目分类 | PWN
    BJDCTF 2nd | Strenuous_Huffman(二进制模拟)
    ssh连接慢优化
    日常问题处理
  • 原文地址:https://www.cnblogs.com/fly-allblue/p/3387345.html
Copyright © 2020-2023  润新知