我的验证码中没有显示错误,因为安全码不匹配

时间:2017-02-08 10:27:25

标签: javascript html

    <div class="row">
                <div class="form-group">
                <label class="control-label col-sm-6"><i>*</i> Address</label>
                <div class="col-sm-3">
                <input id="address" class="address" type="text"   name="address" 
                onchange="IsValidAddress(this.form.address.value)" required="required" >     
                </div>
                <div class="col-sm-3">
                </div>
                </div>
                </div>
                <div>&nbsp;</div>
                <div class="row">
                <div class="form-group">
                <label class="control-label col-sm-6"><i>*</i> Zip Code :</label>
                <div class="col-sm-3">
       <input id="zipcode" class="zipcode" type="text"  name="zipcode" onchange="IsValidZipCode(this.form.zipcode.value)" required="required" >
    <br />
                </div>
                <div class="col-sm-3">
                </div>
                </div>
                </div>
                <div>&nbsp;</div> 
                <div class="row">
                <div class="form-group">
                <label class="control-label col-sm-6"><i>*</i> City</label>
                <div class="col-sm-3">
                <input class="form-control" name="city" type="text" id="city" required="required" value="">   
                </div>
                <div class="col-sm-3">
                </div>
                </div>
                </div>
                <div>&nbsp;</div>
                <div class="row">
                <div class="form-group">
                <label class="control-label col-sm-6"><i>*</i> State</label>
                <div class="col-sm-3">
                <input class="form-control" name="state" type="text" id="state" value="" required ="required">     
                </div>
                <div class="col-sm-3">
                </div>
                </div>
                </div>
                <div>&nbsp;</div>
                <div class="row">
                <div class="form-group">
                <label class="control-label col-sm-6"><i>*</i> Country</label>
                <div class="col-sm-3">
                <input class="form-control" name="country" type="text" id="country" value="" required="required">    
                </div>
                <div class="col-sm-3">
                </div>
                </div>
                </div>
                <div>&nbsp;</div>
                <div class="row">
                <div class="form-group">
                <label class="control-label col-sm-6">&nbsp;Fax</label>
                <div class="col-sm-3">
                <input class="form-control" name="fax" type="text" id="fax" value="" required ="required">    
                </div>
                <div class="col-sm-3">
                </div>
                </div>
                </div>
                <div>&nbsp;</div>
                <div class="row">
                <div class="form-group">
                <label class="control-label col-sm-6"><i>*</i> Captcha</label>
            <div class="col-sm-2">
            </div>
            <div class="col-sm-3">
        <form name="review" ACTION="playing-cards-quote.php" METHOD="POST" onsubmit="return checkform(this);">
    <font color="#DD0000"></font> <span id="txtCaptchaDiv" style="background-color:#A51D22;color:#FFF;padding:5px"></span>
    <input type="hidden" id="txtCaptcha" />


    <input type="text" name="txtInput" id="txtInput" size="15" />
    <input type="submit" value="Submit" class="btn1" name="submit" id="send">       
    </form>


    <script type="text/javascript">
    function checkform(theform){
    var why = "";

    if(theform.txtInput.value == ""){
    why += "- Security code should not be empty.\n";
    }
    if(theform.txtInput.value != ""){
    if(ValidCaptcha(theform.txtInput.value) == false){
    why += "- Security code did not match.\n";
    }
    }
    if(why != ""){
    alert(why);
    return false;
    }
    }

    //Generates the captcha function
    var a = Math.ceil(Math.random() * 9)+ '';
    var b = Math.ceil(Math.random() * 9)+ '';
    var c = Math.ceil(Math.random() * 9)+ '';
    var d = Math.ceil(Math.random() * 9)+ '';
    var e = Math.ceil(Math.random() * 9)+ '';

    var code = a + b + c + d + e;
    document.getElementById("txtCaptcha").value = code;
    document.getElementById("txtCaptchaDiv").innerHTML = code;

    // Validate the Entered input aganist the generated security code function
    function ValidCaptcha(){
    var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
    var str2 = removeSpaces(document.getElementById('txtInput').value);
    if (str1 == str2){
    return true;
    }else{
    return false;
    }
    }

    // Remove the spaces from the entered and generated code
    function removeSpaces(string){
    return string.split(' ').join('');
    }
    </script>






    </div>
    <div class="col-sm-3">
            </div>
            </div>
            <div>&nbsp;</div>
            <div class="row">
            <div class="form-group">
            <div class="col-sm-12">
            <center>

            </center>
            </div>
            </div>
            </div>
            <div>&nbsp;</div>
            </div>
            </fieldset>
            </form>
            </div>
            </div>
            </div>
            <!---footer---><?php include("include files/footer.php");?>
        </body>
    </html>


my javascript code is written above html code but in this code i m writing below html code ......

这会影响我调用验证码的功能吗?     没有显示我的错误,如安全性不匹配?     如果我点击提交按钮,它会将我重定向到感谢页面     验证码验证有什么问题     为什么它没有验证匹配没有正确完成 为什么它直接接受表格而没有验证capctha? 代码有什么问题? 无法识别错误pease帮帮我

0 个答案:

没有答案