$(document).ready(function(){ //For Card Number formatted input var cardNum = document.getElementById('cr_no'); cardNum.onkeyup = function (e) { if (this.value == this.lastValue) return; var caretPosition = this.selectionStart; var sanitizedValue = this.value.replace(/[^0-9]/gi, ''); var parts = []; for (var i = 0, len = sanitizedValue.length; i < len; i += 4) { parts.push(sanitizedValue.substring(i, i + 4)); } for (var i = caretPosition - 1; i >= 0; i--) { var c = this.value[i]; if (c < '0' || c > '9') { caretPosition--; } } caretPosition += Math.floor(caretPosition / 4); this.value = this.lastValue = parts.join('-'); this.selectionStart = this.selectionEnd = caretPosition; } //For Date formatted input var expDate = document.getElementById('exp'); expDate.onkeyup = function (e) { if (this.value == this.lastValue) return; var caretPosition = this.selectionStart; var sanitizedValue = this.value.replace(/[^0-9]/gi, ''); var parts = []; for (var i = 0, len = sanitizedValue.length; i < len; i += 2) { parts.push(sanitizedValue.substring(i, i + 2)); } for (var i = caretPosition - 1; i >= 0; i--) { var c = this.value[i]; if (c < '0' || c > '9') { caretPosition--; } } caretPosition += Math.floor(caretPosition / 2); this.value = this.lastValue = parts.join('/'); this.selectionStart = this.selectionEnd = caretPosition; } // Radio button $('.radio-group .radio').click(function(){ $(this).parent().find('.radio').removeClass('selected'); $(this).addClass('selected'); }); })
Script Copy url Copy url with Tag
Bootstrap CSS https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css copy copy script
Bootstrap JS https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js copy copy script
Jquery https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js copy copy script

Related Snippets

view all snippets
About this snippet

Bootstrap 4 Gift card payment form snippet is created by Omkar Bailkeri using Bootstrap 4.3.1, Javascript 3.2.1. This snippet is free and open source hence you can use it in your project.Bootstrap 4 Gift card payment form snippet example is best for Bootstrap payment, Bootstrap forms, responsive.A great starter for your new awesome project with 1000+ Font Awesome Icons, 4000+ Material Design Icons and Material Design Colors at BBBootstrap.com.

Join BBBootstrap community

Contribute an awesome snippet to help other developer and designers