注册验证码

273次浏览 更新日期:2025-05-11 12:40:47 分类:程序交流 评论:3

大家好,我在注册会员时,所有输入框都输入正确,唯独验证码输入错误,在验证码输入错误的同时,验证码没有自动更新,请兄弟们指点一下,如下图。

                                   



 1746938282188808.png


script如下

$(document).on("click", ' #send-btn', function () {

        const email = $('#email').val();

        const sendBtn = $(this);

        sendBtn.prop('disabled', true);

        if(!email){

            layer.tips('请填写注册邮箱!', '#email', {

                tips: [3, 'red'],time: 6000

            });

            return false;

        }

        if(!isEmail(email)){

            layer.tips('邮箱格式错误,请重新填写!', '#email', {

                tips: [3, 'red'],time: 6000

            });

            return false;

        }

        $.ajax({

            type: 'POST',

            url: "{U('api/index/send_email_code')}",

            data: {

                email: email

            },

            success: function (response) {

                // 发送邮件成功后,启动倒计时

                let seconds = 60;

                // 启动倒计时

                const countdownInterval = setInterval(() => {

                    seconds--;

                    if (seconds <= 0) {

                        clearInterval(countdownInterval);

                        sendBtn.html('发送邮件验证码');

                        sendBtn.prop('disabled', false);

                    } else {

                        sendBtn.html('已发送, ' + seconds + '秒');

                    }

                }, 1000);

            },

            error: function (data) {

                layer.msg(data.responseJSON.msg, {icon: 2, offset: '16px', anim: 'slideDown', time: 5000});

                sendBtn.prop('disabled', false);

            }

        });

    });

    function tijiao(obj, url){

    $.ajax({

    type: 'POST',

    url: url, 

    data: $(obj).serialize(),

    dataType: "json", 

    success: function (msg) {

    if(msg.status == 1){

    layer.msg(msg.message, {icon:1,time: 2000}, function(){

    window.location.href = msg.url;

    });

    }else{

    layer.msg(msg.message, {icon:2,time: 2500});

    }

    }

    })

return false;

}


我来说两句
  • oolaile
    oolaile 1月前
    弄好了,谢谢大佬
    1
    回复
  • $('#code+img').attr('src',$('#code+img').attr('src') + '?' + Math.random());根据你代码结构来改节点就行
    1
    回复
  •    function tijiao(obj, url){
    
        	$.ajax({
    
        		type: 'POST',
    
        		url: url, 
    
        		data: $(obj).serialize(),
    
        		dataType: "json", 
    
        		success: function (msg) {
    
        			if(msg.status == 1){
    
        				layer.msg(msg.message, {icon:1,time: 2000}, function(){
    
        					window.location.href = msg.url;
    
        				});
    
        			}else{
                                    $('#code+img').attr('src',$('#code+img').attr('src') + '?' + Math.random());
        				layer.msg(msg.message, {icon:2,time: 2500});
    
        			}
    
        		}
    
        	})
    
    	return false;
    
    }
    1
    回复
作者信息
发布见解
发内容 回顶部