第一个文本框上的自动标签不起作用

时间:2015-12-11 19:59:38

标签: javascript html textbox credit-card

以下是用于创建信用卡的代码。我唯一的问题是自动标签不能用于我的文本框,其id为card.i有一个外部文件用于自动标签,我已经在html代码下附加了代码。提前谢谢。

    <head>
    <title>Credit Card</title>

     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
     <script src="jquery.autotab.js"></script>
     <script src="Jstepper.js"></script>
    </head>
    </body oncopy="return false" oncut="return false" onpaste="return false">
    <style>
    #Month{
     width: 20px;
     }
     #Year{
     width: 40px;
     }
     #Cvc{
     width: 30px;
     }
    </style>
     <p>Payment:
         Credit card<input type="radio" id='radio_1' name='payment' value="credit">
          <div class="text1">
            <form name="cardForm" method="post">
                <p>Card number:<input type="text" name="FirstField" id='card' value="" 
                onKeyup="autotab(this,document.cardForm.SecondField)" maxlength=16 >
                Expiration: Month:-<input type="text" name="SecondField"  id='Month' value=""
                onKeyup="autotab(this,document.cardForm.ThirdField)"  maxlength=2 >
                Year:-<input type="text" id='Year' name="ThirdField" value="" onKeyup="autotab(this, document.cardForm.FourthField)"maxlength=4></p>
                3 digit CVC:-<input type="text" name="FourthField" id='Cvc' value="" maxlength=3></p>
            </form>       
          </div>    

    </body>
    <!--Jump when expiration number is typed-->
    <!--month and year-->
    <!--exp date has to greater than or equal to current date -->
    <!--on every keypress check if the length is 16-->
    <!--macthes-->
    <!-- Import numeric from src folder-->
        <script src="numeric.js"></script>
    <script>
    //autotab doesnt work for the first feild
    //can still copy and paste text
        $(document).ready(function () {
         $(".text1").hide();
            $("#radio_1").click(function () {
                    <!--passes card id to keypress function-->
                    $('#card').keypress();
                    //disable copy and paste
                    $('#card').bind();
                    $('#Month').keypress();
                    $('#Month').bind();
                    $('#Month').jStepper({minValue:0, maxValue:12});

                    $('#Year').keypress();
                    $('#Year').bind();

                    $('#Cvc').keypress();
                    $('#Cvc').bind();
                    $(".text1").show();
                }); 
            });

    </script>

<html>  

/*
Auto tabbing script- By JavaScriptKit.com
http://www.javascriptkit.com
This credit MUST stay intact for use
*/

function autotab(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus()
}

1 个答案:

答案 0 :(得分:0)

{{1}}