【问题标题】:i want pass the 45 second quickly using console or java script我想使用控制台或 javascript 快速通过 45 秒
【发布时间】:2016-12-12 03:13:00
【问题描述】:

我想使用控制台或 java script.form 快速通过 45 秒。现在我该怎么做 .. 页面 Html 是

<html><head>        
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Appointment Login</title>


        <link href="css/Online_regular.css" rel="stylesheet" type="text/css">
        <link href="css/jquery_theme_tvoa.css" rel="stylesheet" type="text/css">

    <link rel="icon" href="images/favicon.ico">   
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery-ui.js"></script>
    <script type="text/javascript" src="js/declarations.js?rev=05082016"></script>
    <style>
        #form_info{
            display:none;
            position: fixed;
            margin:0 auto;
            top: 1%;
            left: 50%;  
            margin-left: -25%;  
            width: 50%;
            height: 50%;               
            filter:alpha(opacity=50);
            -moz-opacity:0.5;
            -khtml-opacity: 0.5;
            opacity: 1;
            z-index: 10000;
        }
        #overlay{
            width:100%;
            height:100%;position: fixed;
            z-index:0;
            top: 0;
            left:0;
            background:rgba(0,0,0,0.5);
        }
        ul.form_info_list {
            font-weight: bold;
        }
        ul.form_info_list li {
            font-weight: normal;
        }
        .know_req_info_span{
            color:#2080c9;
            font-size: 1.1em;
            cursor:pointer;
        }
        ul.errorMessage li{
            list-style-type: none;
            color:red;
        }
    </style> 

    <script>
        function refreshCaptcha()
        {
            try
            {
                var d = new Date();
                var n = d.getTime();
                //document.getElementById("capt").src="images/1.jpg";
                //alert("hi");
                document.getElementById("capt").src = "captcha?rand=" + n;
            }
            catch (e)
            {
                alert(e);
            }
            return false;
        }

        function image_loaded() {
            var width = $('#capt').css('width');

            if (width === 200 || width === "200px" || width === '200px') {
                $('#label1').html("Access Code");
                $('#label2').html("Enter Access Code");
            }
            else {
                $('#label1').html("Question");
                $('#label2').html("Answer");
            }
        }


        window.onload = function () {
            document.onkeydown = function (e) {
                return (e.which || e.keyCode) != 116;
            }
        }
        $(document).ready(function () {


            });

          </script>
</head>
<body onload="backButtonOverride()">           
    <br>

    <div class="wrapper">
        <div class="pageHeader"></div> 
        <div class="pageHeading1 text_center">
            Appointment Login
            <a href="index.html"><img src="./images/home.png" style=" width: 30px; height:26px;" align="right"></a>
        </div>
        <div class="container">
            <div class="form_container">   
                <form method="post" autocomplete="off" action="Get_Appointment" onsubmit="return validate_appointmentLogin_form();">  
                    <!--onsubmit="return validate_appointmentLogin_form()" -->
                    <div class="row text_center" id="generate_otp_msg" style="font-weight:bold;font-size: 14px;padding-bottom: 10px;color:#BF0D0D">

                    </div>
                    <div class="row">
                        <div class="col-31"></div>
                        <div class="col-32">
                            <input name="otp_required" value="generate_otp" id="generate_otp" onclick="otpmgt()" type="radio"> I want to Generate OTP
                            <br>
                            <input name="otp_required" value="have_otp" id="have_otp" onclick="otpmgt()" type="radio">I have received OTP 

                            <br><input name="otp_required" value="send_alotment_sms" id="send_alotment_sms" onclick="otpmgt()" type="radio"> Re-send Appointment Confirmation SMS.</div>
                        <div class="col-33"></div> 
                    </div>

                    <div class="row"> 
                        <div class="col-31 mandatory">Application Id</div>
                        <div class="col-32"><input name="filerfno" id="application_id" size="50" maxlength="12" title="Please Enter your Application Id" value="" type="text"></div>
                        <div class="col-33">Please enter application id</div> 
                    </div>
                    <div class="row"> 
                        <div class="col-31 mandatory">Passport Number</div>
                        <div class="col-32"><input name="passport_no" id="passport_no" size="50" maxlength="14" title="Please Enter your Passport No. As in Passport" value="" type="text"></div>
                        <div class="col-33">Please enter passport no</div> 
                    </div>
                    <div class="row"> 
                        <div class="col-31 mandatory"> <img src="DisplayDynamicField1"></div>
                        <div class="col-32"><input name="121658" class="textBoxDashed app_field" size="20" maxlength="50" onkeyup="chkString(this)" onblur="trim1(this);" type="text"></div>
                        <div class="col-33"></div> 
                    </div>
                    <div class="row"> 
                        <div class="col-31 mandatory"> <img src="DisplayDynamicField2"></div>
                        <div class="col-32"><input name="813988" class="textBoxDashed app_field" size="20" maxlength="50" onkeyup="chkString(this)" onblur="trim1(this);" type="text"></div>
                        <div class="col-33"></div> 
                    </div>
                    <div class="row cotp" style=""> 
                        <div class="col-31 mandatory ">OTP</div>
                        <div class="col-32"><input name="otp" id="otp" size="50" maxlength="6" value="" type="password"></div>
                        <div class="col-33"></div> 
                    </div>
                    <div class="row">
                        <div class="col-1" id="label1">Question</div>
                            <div class="col-2"> <img src="captcha" id="capt" onload="image_loaded();" style="display: inline">
                            </div>
                            <div class="col-3"><a href="#" onclick="return refreshCaptcha();" style="vertical-align: baseline"><img src="images/refresh.png" style="width:30px;height:30px;display: inline"></a></div>
                        </div>

                        <div class="row">
                                <div class="col-1 mandatory" id="label2">Answer</div>
                            <div class="col-2"><input name="captcha" id="captcha" maxlength="20" type="text"></div>
                                <div class="col-3 errorify" style="list-style-type: none">  <ul class="errorMessage">
        <li><span>Invalid Captcha</span></li>   </ul>

您可以在 32 秒后提交请求

                </form>
            </div>
            <br><br>
            <b>Instructions for Appointment</b>
            <ul class="instructions_ul text_bold">
                <li>Applicants for tourist visa need an appointment date to submit their applications at IVACs</li>
                <li> A one-time password (OTP) will be sent to mobile phone of the applicant which is required for securing the appointment date.</li>
                <li>Applicants should fill in their details carefully and provide the correct mobile number.</li>
                <li>The appointment will be sent as an SMS on the mobile phone of the applicant. This SMS should be shown by the applicant at the IVAC Center to enter and deposit the application</li>
                <li>OTP can be generated only after the appointment time starts. </li>
                <li>Appointment can be booked only after logging in using OTP. </li>
                <li>OTP is valid for 20 minutes.</li>
                <li>Maximum 3 OTPs can be generated on a given day for a File Number.</li>
            </ul>    
        </div>
    </div>     

<script>
    function generate_otp(filerfno_var,passport_no_var) {
        $('#error_msg').html('');
        var value1_var=document.getElementsByClassName("app_field")[0].value;
        var value2_var=document.getElementsByClassName("app_field")[1].value;

        if(document.getElementById('generate_otp').checked == true)
            var otp_required_var="generate_otp";
        else if(document.getElementById('have_otp').checked == true)
            var otp_required_var="have_otp";
        else if(document.getElementById('send_alotment_sms').checked == true)
            var otp_required_var="send_alotment_sms";

        var otp_var=document.getElementById("otp").value;
        var captcha_var=document.getElementById("captcha").value;

        //http://localhost:8084/struts_bgd/json/GenerateOtp?filerfno=BGDDV0004116&passport_no=PASS123&value1=TEST&value2=TEST

        $.ajax({
            type: "POST",
            url: "json/GenerateOtp",
            dataType: "json",
            data: {filerfno : filerfno_var,passport_number:passport_no_var,value1:value1_var,value2:value2_var,otp_required:otp_required_var,otp:otp_var,captcha:captcha_var},
            success: function (data) {
                //alert(data['sms_output']);                    
                alert(data);
                $('#generate_otp_msg').text(data);
                refreshCaptcha();
                $('#captcha').val('');
                $('#have_otp').prop('checked', false);  
                $('#generate_otp').prop('checked', false);  
                $('#send_alotment_sms').prop('checked', false);  

            }
        })
        .done(function (data) {

        })
        .fail(function () {
            alert("Some problem occurred");
        })
        .always(function () {
        });
    }



    var refreshIntervalId;
    function startTimer(duration, display) {
        var timer = duration, minutes, seconds;
        refreshIntervalId =  setInterval(function () {
            minutes = parseInt(timer / 60, 10)
            seconds = parseInt(timer % 60, 10);
            minutes = minutes < 10 ?  minutes : minutes;
            seconds = seconds < 10 ?  seconds : seconds;
            // display.text(minutes + ":" + seconds);
            display.text(seconds);
            $('#timer_msg').html('You can submit request after '+seconds+' seconds');
            if (--timer < 0) {
                $('#timer_msg').html('<input name="submit_btn" id="btn1" type="submit" class="btn btn-primary"  value="Submit">');                    
                return;
            }
        }, 1000);
    }

    function otpmgt() {
        var otp_check = null;
        $('#error_msg').html('');
        if (document.getElementById('have_otp').checked == true)
        {
            otp_check = document.getElementById('have_otp').value;      
            $('.cotp').css('display', '');
            $('#otp').prop('disabled', false);
            //call timer function
            $('#timer_msg').html('');
            startTimer(45, $('#btn_time'));       
            document.getElementById("otp").disabled = false;
        }
        else if (document.getElementById('generate_otp').checked == true)
        {   //submit request through ajax
            clearInterval(refreshIntervalId);
            alert("OTP will be sent to your registered mobile number.");
            otp_check = document.getElementById('generate_otp').value;
            $('.cotp').css('display', 'none');
            $('#otp').val('');
            $('#otp').prop('disabled', true);
            $('.cappt_mobile').css('display', '');        
            $('#btn1').val('Generate OTP');

            document.getElementById("otp").disabled = true;
            //display submit button now            
            $('#timer_msg').html('<input name="submit_btn" id="btn1" type="submit" class="btn btn-primary"  value="Generate OTP" >');

        } else if (document.getElementById('send_alotment_sms').checked == true)
        {
            clearInterval(refreshIntervalId);
            otp_check = document.getElementById('send_alotment_sms').value;
            $('.cotp').css('display', 'none');
            $('#otp').val('');
            $('#otp').prop('disabled', true);
            $('.cappt_mobile').css('display', 'none');       
            document.getElementById("otp").disabled = true;
            $('#timer_msg').html('<input name="submit_btn" id="btn1" type="submit" class="btn btn-primary"  value="Send Allotment SMS" >');
        }  

    }

    function validate_appointmentLogin_form() {
        var f1 = document.getElementsByClassName('app_field')[0].value;
        var f2 = document.getElementsByClassName('app_field')[1].value;  

        var otp_value = document.getElementById("otp").value;
        var otp_length = otp_value.length;
        var otp_required_val = "";
        var otp_required_check = ($('input[type=radio]:checked').size() > 0);// false    
        var submit = true;
        var result = "";

        if (document.getElementById('application_id') != undefined) {
            result = validate_filenumber($('#application_id').val(), 1);
            if (result != "true")
            {
                errorify($('#application_id'), result);
                submit = false;
            }
            else
            {
                correctify($('#application_id'), "Please enter application id");
            }
        }
        if (document.getElementById('passport_no') != undefined) {
            result = validate_passportNo($('#passport_no').val(), 1);
            if (result != "true")
            {
                errorify($('#passport_no'), result);
                submit = false;
            }
            else
            {
                correctify($('#passport_no'), "");
            }
        }
        //if(f1 == null || f1.value == "" || isEmpty(f1)||f1.length==0)
        if (f1 == "" || f1.length == 0)
        {
            result = validate_passportNo(f1, 1);
            errorify($(document.getElementsByClassName('app_field')[0]), "Please enter all mandatory details");
            submit = false;
        } else 
        {
            correctify($(document.getElementsByClassName('app_field')[0]), "");
        }
        if (f2 == "" || f2.length == 0)
        {
            //alert("Please Enter All mandtory fields"+document.getElementsByClassName('app_field')[1]);
            errorify($(document.getElementsByClassName('app_field')[1]), "Please enter all mandatory details");
            submit = false;
        }
        else 
        {
            correctify($(document.getElementsByClassName('app_field')[1]), "");
        }
        if (otp_required_check)
        {
            correctify($('#have_otp'), "");
            if (document.getElementById('have_otp').checked == true && otp_value.length == 0) {
                errorify($('#otp'), "Please enter otp");
                submit = false;
                //  alert("Have OTP and Length= 0. Submit = " + submit);
            }
            else
            {
                correctify($('#otp'), "");
            }
            if (document.getElementById('have_otp').checked == true && otp_value.length < 6) {
                errorify($('#otp'), "Please enter correct otp");
                submit = false;
                // alert("Have OTP and Length< 6. Submit = " + submit);
            }
            else 
            {
                correctify($('#otp'), "");
            }          


        }
        else
        {
            errorify($('#have_otp'), "Please select at least one option.");
            submit = false;
        }
        if (document.getElementById('captcha') != undefined) {
            result = validate_captcha($('#captcha').val(), 1);

            if (result != "true")
            {
                errorify($('#captcha'), result);
                submit = false;
            }
            else
            {
                correctify_lowercase($('#captcha'), "");
            }
        }

        //if generate otp is clicked then submit function by ajax else submit to action    
        if(document.getElementById('generate_otp').checked == true && submit == true){
            //call ajax function to generate otp    
            //disable submit button here


            generate_otp($('#application_id').val(),$('#passport_no').val());

            submit=false;
        }


        return submit;
    }

</script>

enter image description here

请帮我做这件事..

【问题讨论】:

  • 您能否将您的代码放入 jsfiddle 或其他东西中,以便我们查看发生了什么,并使用代码来弄清楚如何使其正常工作?

标签: javascript console


【解决方案1】:
// store the current time (when the script loads)
var start = new Date();

// in the form submit event
function submit(e) {
  if (new Date() - start < 45000) {
    // stop the form submitting
    e.preventDefault();
    // show the message
    msg45secs.style.display = "block";
  }
  else {
    // whatever you want to do if the time checks out
    // if you want to just let it submit, you don't need to do anything. you can remove the `else` if you like.
  }
}

【讨论】:

    猜你喜欢
    • 2012-06-10
    • 1970-01-01
    • 2017-05-03
    • 2011-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-11
    相关资源
    最近更新 更多