douxun7992 2015-07-06 05:48
浏览 37

服务器幻灯片验证活动js功能

function checkpassword(){
    var password_value = $("#reg-password").val();

    if(password_value === ""){
        //password emtpy
        $("#password-result").html('Please make a password');
        $("#password-result").css('color', 'red');
        $('#reg-password').css('border-color', 'red');
    }else if (password_value.length < 6){
        //password is too shot 6 digi
        $("#password-result").html('Your password is too short.');
        $("#password-result").css('color', 'red');
        $('#reg-password').css('border-color', 'red');
    }else{
        //password passed
        $("#password-result").html('');
        $('#reg-password').css('border-color', '#dfe0e6');
        return true;
    }
    return false;
}

this is a validation function with client side , i wanted to make a sever side which will active the this function , exp if

if(isset($_POST['submit'])){
if(empty($_POST['submit'])){
//some how active js (password_value === "");
}
}

how should i make those or i am making this validation wrong.

  • 写回答

2条回答 默认 最新

  • donglv6960 2015-07-06 06:03
    关注

    The if(empty($_POST['submit'])){ loop is not needed. But it makes no sense running a JavaScript function with PHP.

    JavaScript validation is running before the PHP validation i.e. you must call the function client-side with JavaScript.

    If you want to check the password, while the user types, AJAX is the way to go! Here you call a PHP script with JavaScript code.

    Example: http://www.shawngo.com/examples/ajax-username-check/

    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程