$(function(){ $(window).keydown(function (event) { if ((event.keyCode == 13) ) { event.preventDefault(); console.log('pressed enter') return false; } }); $('.nextBtn').click(function(e){ e.preventDefault(); $('#mytabs a[href="#intro"]').attr('data-toggle','tab') $('#mytabs a[href="#first"]').tab('show').attr('data-toggle','tab'); scrollTo('#mytabs a[href="#first"]'); }) jQuery('a[disable]').on('click',function(event){ event.preventDefault(); console.log('hello'); return false; }) }) var slider = document.getElementById("myRange"); var output = document.getElementById("demo"); if(slider){ output.innerHTML = slider.value; slider.oninput = function() { output.innerHTML = this.value; } } function validateForm(){ jQuery('.validation-error').hide(); var is_valid = true; var inputs = [ "client_ref", "adviser_name", "adviser_firm", "adviser_ref", "client_name","day", "month","year","gender" ]; inputs.forEach(function(name){ console.log(`[name="${name}"] : `, jQuery(`[name="${name}"]`).val()) var value = jQuery(`[name="${name}"]`).val(); if (!value || value.length <= 0 ){ is_valid = false; $('#mytabs a[href="#first"]').tab('show'); // if (!is_valid) { // } setTimeout(() => { jQuery(`[name="${name}"]+.validation-error`).show(); }, 40); } }); return is_valid; } jQuery('#nexttab').on('click',function(){ var is_valid = validateForm(); if (!is_valid) { setTimeout(() => { if( jQuery('#first .validation-error:visible').length>=1 ){ scrollTo( '#first .validation-error:visible:first' ); }else{ scrollTo('#first .information-formdata'); } }, 10); return false; }else{ $('#mytabs a[href="#second"]').tab('show'); $('#mytabs a[href="#second"]').attr('data-toggle', 'tab') scrollTo('.tab-pane.active'); } }); jQuery('#thirdtab').on('click',function(){ var is_valid = validateForm(); if(!is_valid){ $('#mytabs a[href="#first"]').tab('show'); } }); function scrollTo(selector){ setTimeout(() => { $('html,body').animate({ scrollTop: $(selector).offset().top = 10 }, 1000); }, 200); }