私は学校のためのピザのウェブサイトで働いています。カスタムクレジットカード番号の長さ
ここに私が答える必要がある質問があります。 * Visa、MasterCard、American Expressの3種類のクレジットカードから選択できます。クレジットカードの種類に基づいて、クレジットカード番号の長さを制限します.16桁のVisaとMasterCard、15桁のAmerican Express。 *
現在、ページは設定されているため、ピザをピックアップするときに支払うか、クレジットカードでオンラインで支払うかをユーザーが選択します。
オンラインラジオボックスがオンになっていると、クレジットカード名のラジオボックスが表示されます。あなたは、HTMLコードに見ることができるように配信されるまでクレジットカードのラジオボックスを隠すため
HTMLコード
<p> Payment Method</p>
<input id="paypickup" type="radio" name="rbRating"
value="Pick Up" checked />Pay on pickup
<input id="online" type="radio" name="rbRating"
value="online" />Online
<div id="hidden2" class="textinput">
<input id="visa" type="radio" name="cardtype"
value="Visa" onclick="showMe('visanum')"/>Visa
<input id="mastercard" type="radio" name="cardtype"
value="MasterCard" onclick="showMe('masternum')"/>MasterCard
<input id="americanexpress" type="radio" name="cardtype"
value="American Express" onclick="showMe('americaninfo')"/>American Express
</div>
<div id="visainfo">
<label for="visanum">Credit Card Number</label>
<input id="visanum" type="text" name="cardnum" maxlength="16" />
</div>
<div id="masterinfo">
<label for="masternum">Credit Card Number</label>
<input id="masternum" type="text" name="cardnum" maxlength="16" />
</div>
<div id="americaninfo">
<label for="americannum">Credit Card Number</label>
<input id="americannum" type="text" name="cardnum" maxlength="15" />
</div>
<button type="submit" value="Submit">Submit</button>
<button type="reset" value="Reset">Reset</button>
JSコードが
$(document).ready(function() {
$('input[type="radio"]').click(function() {
if($(this).attr('id') == 'paypickup') {
$('#hidden2').hide();
}
if($(this).attr('id') == 'online') {
$('#hidden2').show();
}
});
});
をチェックされて、私は複数を作成することによって、これを試みてみましたmaxlengthのテキストボックス。しかし、私はすぐにこれが非効率で混乱していることを認識しました。
私はこれらの種類のものに非常に新しいです。