<html lang="en">
<head>
<link rel="stylesheet" href="style.css" />
<li id="visa">
<section class="credit-card visa gr-visa">
<div class="logo">visa</div>
<form>
<h2>Payment Details</h2>
<ul class="inputs">
<li>
<label>Card Number</label>
<input type="text" name="card_number" pattern="[0-9]{13,16}" value="9842 9472 9457 9472" class="full gr-input" required />
</li>
<li>
<label>Name on card</label>
<input type="text" name="card_name" size="20" class="month gr-input" required />
<li class="expire last">
<label>Expiration</label>
<div class="dropdown">
<select name="one" class="dropdown-select month gr-input">
<option value="">Month</option>
<option value="1">Jan</option>
<option value="2">Feb</option>
<option value="3">Mar</option>
<option value="4">Apr</option>
<option value="5">May</option>
<option value="6">Jun</option>
<option value="7">Jul</option>
<option value="8">Aug</option>
<option value="9">Sep</option>
<option value="10">Oct</option>
<option value="11">Nov</option>
<option value="12">Dec</option>
</select>
</div>
<div class="dropdown">
<select name="one" class="dropdown-select year gr-input">
<option value="">Year</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
</select>
</div>
<div class="clearfix"></div>
</li>
<li class="cvc-code last">
<label>CVV Code</label>
<input type="text" name="cvc_code" value="174" size="10" class="gr-input" required />
</li>
<input type="post" name="submit" value="Pay Now" class="fsSubmitButton"/>
<div class="clearfix"></div>
</ul>
</form>
<div class="watermark">visa</div>
</section>
</li>
<li id="mastercard">
<section class="credit-card mastercard gr-mastercard">
<div class="logo"><div></div><div></div></div>
<form>
<h2>Payment Details</h2>
<ul class="inputs">
<li>
<label>Card Number</label>
<input type="text" name="card_number" pattern="[0-9]{13,16}" value="9842 9472 9457 9472" class="full gr-input" required />
</li>
<li>
<label>Name on card</label>
<input type="text" name="card_name" size="20" class="month gr-input" required />
<li class="expire last">
<label>Expiration</label>
<div class="dropdown">
<select name="one" class="dropdown-select month gr-input">
<option value="">Month</option>
<option value="1">Jan</option>
<option value="2">Feb</option>
<option value="3">Mar</option>
<option value="4">Apr</option>
<option value="5">May</option>
<option value="6">Jun</option>
<option value="7">Jul</option>
<option value="8">Aug</option>
<option value="9">Sep</option>
<option value="10">Oct</option>
<option value="11">Nov</option>
<option value="12">Dec</option>
</select>
</div>
<div class="dropdown">
<select name="one" class="dropdown-select year gr-input">
<option value="">Year</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
</select>
</div>
<div class="clearfix"></div>
</li>
<li class="cvc-code last">
<label>CVV Code</label>
<input type="text" name="cvc_code" value="174" size="10" class="gr-input" required />
</li>
<input type="post" name="submit" value="Pay Now" class="fsSubmitButtonM"/>
<div class="clearfix"></div>
</ul>
</form>
<div class="watermark"><div></div><div></div></div>
</section>
</li>
Two forms are here... When a number starting with 9 is entered in the credit card field, the first form should be displayed. If a number starting with 4 is entered, the Visa form should be shown.
The CSS code is as follows:
/* === Basic reset === */
* { margin: 0; padding: 0; outline: none; box-sizing:border-box; }
a>img { border: none; }
header, footer, article, section, nav, aside { display: block; }
/* === General === */
body {
font-family:Arial;
font-size: 14px;
background:#ddd;
}
.clearfix {
clear:both;
}
/* === Credit Card === */
.credit-card {
display:block;
position:relative;
width:93.75%; /* This is 300px on 320px wide screen */
max-width:500px; /* Just to make sure that it doesnt get crazy on bg screens */
min-width:300px; /* And make sure that it contains at least some size */
margin:30px auto;
padding:20px;
overflow:hidden;
border-radius:6px;
z-index:1;
}
.credit-card .inputs {
list-style:none;
margin-top:30px;
}
.credit-card .inputs li {
margin-bottom:30px;
}
.credit-card .inputs li.last {
margin-bottom:10px;
}
.credit-card .inputs li.expire {
float:left;
width:70%;
margin-right:5%;
}
.credit-card .inputs li.expire input{
float:left;
width:35%;
}
.credit-card .inputs li.expire input.month{
width:30%;
margin-right:5%;
}
.credit-card .inputs li.cvc-code {
float:right;
width:20%;
}
.creditcatd .inputs ul.cvc-code{
display: inline;
}
.credit-card .inputs li.cvc-code input {
width:70%;
}
.credit-card .watermark {
position:absolute;
z-index:10;
}
.credit-card form {
position:relative;
z-index:50;
}
.credit-card .logo {
position:absolute;
top:15px;
right:20px;
text-transform:uppercase;
font-weight:bold;
}
/* === Visa === */
.visa {
color:#fff;
box-shadow: 0px 0px 4px rgba(0,0,0,0.8), inset 0px 1px 3px rgba(255,255,255,0.3), inset 0px 0px 2px rgba(255,255,255,0.2);
}
.visa h2 {
text-shadow:1px 1px 2px rgba(17,121,173,0.8);
}
.visa .logo {
color:rgba(255,255,255,0.9);
font-size:2em;
font-style:italic;
text-shadow:0px 0px 3px rgba(17,123,173,0.9);
}
.vis...
<a href="http://fethr.com/paymentpage/creditcard.html" rel="nofollow">http://fethr.com/paymentpage/creditcard.html</a></p>
<p>This link shows the demo of two forms, but one form (Visa form) may be shown as default. When a number starting with 9 is entered, the CSS should be changed accordingly.</p>
<p>I have a JavaScript function which can switch between the forms by clicking a link. Instead of clicking the link, I need the form to change based on the input provided in the credit card field.</p>
<pre><code>jQuery(document).ready(function(){
// Switch cards
jQuery('.switchCard').click(function(e){
var newCard = jQuery(this).attr('href');
e.preventDefault();
jQuery('.cards li.active').fadeOut('fast',function(){
jQuery(this).removeClass('active');
jQuery(newCard).fadeIn('fast',function(){
jQuery(newCard).addClass('active');
});
});
});
});
I just require modifications to the above JavaScript code so that the card form changes dynamically based on the input received in the credit card field.