How we can create a card checkout form using HTML CSS JavaScript? Solution: See this Credit Card Details Form With CSS jQuery, Card Checkout Form.
Previously I have shared many types of forms, but this something different because it is card details form UI. Basically, card checkout form is the form when we checkout any product on e-commerce then we have to put card details for paying that is the card checkout/details form. These kinds of form use every website which accepts online payment.
Today you will learn to create Card Checkout Form UI design. There is a form for collecting card details like card number, cardholder name, expiry date, CVV. And also you can show the information visually in the card UI which is placed above the form, also this visual card will flip back when entering CVV.
So, Today I am sharing Credit Card Details Form With CSS jQuery. There the layout is created using HTML and CSS, and the functions are created using jQuery which is JS library. This is a complete card checkout form that you can use on your website after backend integration. I am sure that you will definitely like this card’s details form UI design.
If you are thinking now how this card checkout form actually is, then see the preview given below.
Preview Of Card Checkout UI Design
See this video preview to getting an idea of how this form’s UI design looks like.
Now you can see this visually, you also can see it live by pressing the button given above. If you like this, then get the source code of its.
You May Also Like:
- JavaScript Random Password Generator
- jQuery Floating Label Animation
- Bootstrap Button Group
- Multi Step Form With JavaScript
Credit Card Details Form With CSS jQuery Source Code
Before sharing source code, let’s talk about it. First I have created the card’s layout using HTML, there are lots of div created for creating the whole layout. There is a visa logo which is completely based on SVG, it is not a kind of JPG or PNG image. After that, I have created the form using HTML <form> property and placed the kinds of input like text input, select input, number input, etc.
Now using CSS I have placed all the elements on the right place, as you can see in the preview. There I have used gradient in background, card, and in submit button. There is a lock icon on the submit button, for that I have used an external icon library. If you see in the card there is earth globe image in the background of the card, I have linked an SVG image in the background.
With CSS I have done many more things like all kind of basic and advance things. jQuery handling here the main features of this program, like writing card Infos on the card according to form fillup. For that function, I have used JS keyup command (info). Also jQuery handling the flip animation according to form section and the number validation.
Left all other things you will understand after getting the codes, I can’t explain all in writing. For creating this program you have to create 3 files for that. First for HTML, second for CSS, and the third for JavaScript. Follow the steps to creating this without any error.
index.html
Create an HTML file named ‘index.html‘ and put these codes given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
<!DOCTYPE html> <!--Code By Webdevtrick ( https://webdevtrick.com )--> <html lang="en" > <head> <meta charset="UTF-8"> <title>Credit Card Details | Webdevtrick.com</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Inconsolata'> <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Open+Sans'> <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'> <link rel="stylesheet" href="style.css"> </head> <body> <div class="checkout"> <div class="credit-card-box"> <div class="flip"> <div class="front"> <div class="chip"></div> <div class="logo"> <svg version="1.1" id="visa" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="47.834px" height="47.834px" viewBox="0 0 47.834 47.834" style="enable-background:new 0 0 47.834 47.834;"> <g> <g> <path d="M44.688,16.814h-3.004c-0.933,0-1.627,0.254-2.037,1.184l-5.773,13.074h4.083c0,0,0.666-1.758,0.817-2.143 c0.447,0,4.414,0.006,4.979,0.006c0.116,0.498,0.474,2.137,0.474,2.137h3.607L44.688,16.814z M39.893,26.01 c0.32-0.819,1.549-3.987,1.549-3.987c-0.021,0.039,0.317-0.825,0.518-1.362l0.262,1.23c0,0,0.745,3.406,0.901,4.119H39.893z M34.146,26.404c-0.028,2.963-2.684,4.875-6.771,4.875c-1.743-0.018-3.422-0.361-4.332-0.76l0.547-3.193l0.501,0.228 c1.277,0.532,2.104,0.747,3.661,0.747c1.117,0,2.313-0.438,2.325-1.393c0.007-0.625-0.501-1.07-2.016-1.77 c-1.476-0.683-3.43-1.827-3.405-3.876c0.021-2.773,2.729-4.708,6.571-4.708c1.506,0,2.713,0.31,3.483,0.599l-0.526,3.092 l-0.351-0.165c-0.716-0.288-1.638-0.566-2.91-0.546c-1.522,0-2.228,0.634-2.228,1.227c-0.008,0.668,0.824,1.108,2.184,1.77 C33.126,23.546,34.163,24.783,34.146,26.404z M0,16.962l0.05-0.286h6.028c0.813,0.031,1.468,0.29,1.694,1.159l1.311,6.304 C7.795,20.842,4.691,18.099,0,16.962z M17.581,16.812l-6.123,14.239l-4.114,0.007L3.862,19.161 c2.503,1.602,4.635,4.144,5.386,5.914l0.406,1.469l3.808-9.729L17.581,16.812L17.581,16.812z M19.153,16.8h3.89L20.61,31.066 h-3.888L19.153,16.8z"/> </g> </g> </svg> </div> <div class="number"></div> <div class="card-holder"> <label>Card holder</label> <div></div> </div> <div class="card-expiration-date"> <label>Expires</label> <div></div> </div> </div> <div class="back"> <div class="strip"></div> <div class="logo"> <svg version="1.1" id="visa" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="47.834px" height="47.834px" viewBox="0 0 47.834 47.834" style="enable-background:new 0 0 47.834 47.834;"> <g> <g> <path d="M44.688,16.814h-3.004c-0.933,0-1.627,0.254-2.037,1.184l-5.773,13.074h4.083c0,0,0.666-1.758,0.817-2.143 c0.447,0,4.414,0.006,4.979,0.006c0.116,0.498,0.474,2.137,0.474,2.137h3.607L44.688,16.814z M39.893,26.01 c0.32-0.819,1.549-3.987,1.549-3.987c-0.021,0.039,0.317-0.825,0.518-1.362l0.262,1.23c0,0,0.745,3.406,0.901,4.119H39.893z M34.146,26.404c-0.028,2.963-2.684,4.875-6.771,4.875c-1.743-0.018-3.422-0.361-4.332-0.76l0.547-3.193l0.501,0.228 c1.277,0.532,2.104,0.747,3.661,0.747c1.117,0,2.313-0.438,2.325-1.393c0.007-0.625-0.501-1.07-2.016-1.77 c-1.476-0.683-3.43-1.827-3.405-3.876c0.021-2.773,2.729-4.708,6.571-4.708c1.506,0,2.713,0.31,3.483,0.599l-0.526,3.092 l-0.351-0.165c-0.716-0.288-1.638-0.566-2.91-0.546c-1.522,0-2.228,0.634-2.228,1.227c-0.008,0.668,0.824,1.108,2.184,1.77 C33.126,23.546,34.163,24.783,34.146,26.404z M0,16.962l0.05-0.286h6.028c0.813,0.031,1.468,0.29,1.694,1.159l1.311,6.304 C7.795,20.842,4.691,18.099,0,16.962z M17.581,16.812l-6.123,14.239l-4.114,0.007L3.862,19.161 c2.503,1.602,4.635,4.144,5.386,5.914l0.406,1.469l3.808-9.729L17.581,16.812L17.581,16.812z M19.153,16.8h3.89L20.61,31.066 h-3.888L19.153,16.8z"/> </g> </g> </svg> </div> <div class="ccv"> <label>CCV</label> <div></div> </div> </div> </div> </div> <form class="form" autocomplete="off" novalidate> <fieldset> <label for="card-number">Card Number</label> <input type="num" id="card-number" class="input-cart-number" maxlength="4" /> <input type="num" id="card-number-1" class="input-cart-number" maxlength="4" /> <input type="num" id="card-number-2" class="input-cart-number" maxlength="4" /> <input type="num" id="card-number-3" class="input-cart-number" maxlength="4" /> </fieldset> <fieldset> <label for="card-holder">Card holder</label> <input type="text" id="card-holder" /> </fieldset> <fieldset class="card-expire"> <label for="expire-month">Expire date</label> <div class="select"> <select id="expire-month"> <option></option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> </select> </div> <div class="select"> <select id="expire-year"> <option></option> <option>2016</option> <option>2017</option> <option>2018</option> <option>2019</option> <option>2020</option> <option>2021</option> <option>2022</option> <option>2023</option> <option>2024</option> <option>2025</option> </select> </div> </fieldset> <fieldset class="fieldset-ccv"> <label for="card-ccv">CCV</label> <input type="text" id="card-ccv" maxlength="3" /> </fieldset> <button class="btn"><i class="fa fa-lock"></i> submit</button> </form> </div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="function.js"></script> </body> </html> |
style.css
Now create a CSS file named ‘style.css‘ and the codes given here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
/* Code By Webdevtrick ( https://webdevtrick.com ) */ *, *::before, *::after { box-sizing: border-box; } html, body { min-height: 100%; font-family: 'Open sans', sans-serif; } body { background: linear-gradient(130deg, #74ebd5, #ACB6E5); } .form fieldset { border: none; padding: 0; padding: 10px 0; position: relative; clear: both; } .form fieldset.card-expire { float: left; width: 60%; } .form fieldset.card-expire .select { width: 84px; margin-right: 12px; float: left; } .form fieldset.fieldset-ccv { clear: none; float: right; width: 86px; } .form fieldset label { display: block; text-transform: uppercase; font-size: 11px; color: rgba(0, 0, 0, 0.6); margin-bottom: 5px; font-weight: bold; font-family: Inconsolata; } .form fieldset input, .form fieldset .select { width: 100%; height: 38px; color: #333333; padding: 10px; border-radius: 5px; font-size: 15px; outline: none !important; border: 1px solid rgba(0, 0, 0, 0.3); box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.2); } .form fieldset input.input-cart-number, .form fieldset .select.input-cart-number { width: 82px; display: inline-block; margin-right: 8px; } .form fieldset input.input-cart-number:last-child, .form fieldset .select.input-cart-number:last-child { margin-right: 0; } .form fieldset .select { position: relative; } .form fieldset .select::after { content: ''; border-top: 8px solid #222; border-left: 4px solid transparent; border-right: 4px solid transparent; position: absolute; z-index: 2; top: 14px; right: 10px; pointer-events: none; } .form fieldset .select select { -webkit-appearance: none; -moz-appearance: none; appearance: none; position: absolute; padding: 0; border: none; width: 100%; outline: none !important; top: 6px; left: 6px; background: none; } .form fieldset .select select :-moz-focusring { color: transparent; text-shadow: 0 0 0 #000; } .checkout { margin: 150px auto 30px; position: relative; width: 460px; background: white; border-radius: 15px; padding: 160px 45px 30px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1); } .credit-card-box { -webkit-perspective: 1000; perspective: 1000; width: 400px; height: 280px; position: absolute; top: -112px; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%); } .credit-card-box:hover .flip, .credit-card-box.hover .flip { -webkit-transform: rotateY(180deg); transform: rotateY(180deg); } .credit-card-box .front, .credit-card-box .back { width: 400px; height: 250px; border-radius: 15px; -webkit-backface-visibility: hidden; backface-visibility: hidden; background: linear-gradient(135deg, #11998e, #38ef7d); position: absolute; color: #fff; font-family: Inconsolata; top: 0; left: 0; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3); } .credit-card-box .front::before, .credit-card-box .back::before { content: ''; position: absolute; width: 100%; height: 100%; top: 0; left: 0; background: url("https://webdevtrick.com/demos/earth.svg") no-repeat center; background-size: cover; opacity: .05; } .credit-card-box .flip { transition: 0.6s; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; position: relative; } .credit-card-box .logo { position: absolute; top: 9px; right: 20px; width: 60px; } .credit-card-box .logo svg { width: 100%; height: auto; fill: #fff; } .credit-card-box .front { z-index: 2; -webkit-transform: rotateY(0deg); transform: rotateY(0deg); } .credit-card-box .back { -webkit-transform: rotateY(180deg); transform: rotateY(180deg); } .credit-card-box .back .logo { top: 185px; } .credit-card-box .chip { position: absolute; width: 60px; height: 45px; top: 20px; left: 20px; background: linear-gradient(135deg, #ddccf0 0%, #d1e9f5 44%, #f8ece7 100%); border-radius: 8px; } .credit-card-box .chip::before { content: ''; position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: auto; border: 4px solid rgba(128, 128, 128, 0.1); width: 80%; height: 70%; border-radius: 5px; } .credit-card-box .strip { background: linear-gradient(135deg, #404040, #1a1a1a); position: absolute; width: 100%; height: 50px; top: 30px; left: 0; } .credit-card-box .number { position: absolute; margin: 0 auto; top: 103px; left: 19px; font-size: 38px; } .credit-card-box label { font-size: 10px; letter-spacing: 1px; text-shadow: none; text-transform: uppercase; font-weight: normal; opacity: 0.5; display: block; margin-bottom: 3px; } .credit-card-box .card-holder, .credit-card-box .card-expiration-date { position: absolute; margin: 0 auto; top: 180px; left: 19px; font-size: 22px; text-transform: capitalize; } .credit-card-box .card-expiration-date { text-align: right; left: auto; right: 20px; } .credit-card-box .ccv { height: 36px; background: #fff; width: 91%; border-radius: 5px; top: 110px; left: 0; right: 0; position: absolute; margin: 0 auto; color: #000; text-align: right; padding: 10px; } .credit-card-box .ccv label { margin: -25px 0 14px; color: #fff; } .form button { width: 100%; outline: none !important; background: linear-gradient(90deg, #11998e, #38ef7d); text-transform: uppercase; font-weight: bold; border: none; box-shadow: none; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); margin-top: 90px; } .form button .fa { margin-right: 6px; } .btn { display: block; color: white; text-decoration: none; margin: 20px 0; padding: 15px 15px; border-radius: 5px; position: relative; } .btn::after { content: ''; position: absolute; z-index: 1; top: 0; left: 0; width: 100%; height: 100%; transition: all .2s ease-in-out; box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0), 0 3px 3px rgba(0, 0, 0, 0.2); border-radius: 5px; } .btn:hover::after { background: rgba(0, 0, 0, 0.1); box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.2); } |
function.js
The final step, create a JavaScript file named ‘function.js‘ and the codes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
// Code By Webdevtrick ( https://webdevtrick.com ) $('.input-cart-number').on('keyup change', function(){ $t = $(this); if ($t.val().length > 3) { $t.next().focus(); } var card_number = ''; $('.input-cart-number').each(function(){ card_number += $(this).val() + ' '; if ($(this).val().length == 4) { $(this).next().focus(); } }) $('.credit-card-box .number').html(card_number); }); $('#card-holder').on('keyup change', function(){ $t = $(this); $('.credit-card-box .card-holder div').html($t.val()); }); $('#card-holder').on('keyup change', function(){ $t = $(this); $('.credit-card-box .card-holder div').html($t.val()); }); $('#expire-month, #expire-year').change(function(){ m = $('#expire-month option').index($('#expire-month option:selected')); m = (m < 10) ? '0' + m : m; y = $('#expire-year').val().substr(2,2); $('.card-expiration-date div').html(m + '/' + y); }) $('#card-ccv').on('focus', function(){ $('.credit-card-box').addClass('hover'); }).on('blur', function(){ $('.credit-card-box').removeClass('hover'); }).on('keyup change', function(){ $('.ccv div').html($(this).val()); }); setTimeout(function(){ $('#card-ccv').focus().delay(1000).queue(function(){ $(this).blur().dequeue(); }); }, 500); |
That’s It. Now you have successfully created Credit Card Details Form With CSS jQuery, Card Checkout Form Program. If you have any doubt or question comment down below In other words, you can asks me for anything.
Thanks For Visiting, Keep Visiting.
Hey Bro
Loved Your Content, Appreciable. Keep it up.
Thank you.
I am glad chrome mobile saw me this website!
Thank you.
Great creativity
Thank you.
Cool Content
Thank you