// JavaScript Document $(document).ready(function() { applyCascadingDropdowns(); $("#registrationForm").bind("keypress", function(e) { if (e.keyCode == 13) { var tagName = e.target.tagName.toLowerCase(); if (tagName !== "textarea") { return false; } } }); }); $(function() { var registrationWizard_root = $("#RegistrationWizard").scrollable({size: 1, clickable: false}); // some variables that we need var registrationWizard_api = registrationWizard_root.scrollable(), registrationWizard_drawer = $("#ErrorDrawer"); // validation logic is done inside the onBeforeSeek callback registrationWizard_api.onBeforeSeek(function(event, i) { // we are going 1 step backwards so no need for validation if (registrationWizard_api.getIndex() < i) { // 1. get current page var registrationWizard_page = registrationWizard_root.find(".page").eq(registrationWizard_api.getIndex()), // 2. .. and all required fields inside the page registrationWizard_inputs = registrationWizard_page.find(".required :input").removeClass("error"), // 3. .. which are empty registrationWizard_empty = registrationWizard_inputs.filter(function() { return $(this).val().replace(/\s*/g, '') == ''; }); // if there are empty fields, then if (registrationWizard_empty.length) { // slide down the drawer registrationWizard_drawer.slideDown(function() { registrationWizard_drawer.html("Please fill in the empty fields marked with a red border."); // colored flash effect registrationWizard_drawer.css("backgroundColor", "#229"); }); setTimeout("$(\"#ErrorDrawer\").slideUp();",2500); // add a CSS class name "error" for empty & required fields registrationWizard_empty.addClass("error"); // cancel seeking of the scrollable by returning false return false; // everything is good } else { // hide the drawer registrationWizard_drawer.slideUp(); } } // update status bar $("#status li").removeClass("active").eq(i).addClass("active"); }); // if tab is pressed on the next button seek to next page registrationWizard_root.find("button.next").keydown(function(e) { if (e.keyCode == 9) { // seeks to next tab by executing our validation routine registrationWizard_api.next(); e.preventDefault(); } }); });