$('.driver_form input[type="submit"]').click(function() { function checkEmptyVal(id) { if($(id).val() == '') { $(id).click(); $(id).focus(); return false; } } checkEmptyVal('#d_exp_years'); });
var $expYears = $('#d_exp_years'); $('.driver_form').on('submit', function (e) { if ($expYears.val() == '') { e.preventDefault(); $expYears.focus(); return; } });