 $(function() {
	// do something here
 
// Form Validation - empty fields
$('.required').blur(function() {
if ($(this).val().length == 0) {
$(this)
.addClass('input-error')
.after('<div class="input-error-message">This field must be completed</div>');
}
});
$('.required').focus(function() {
$(this)
.removeClass('input-error')
.next('div')
.remove();
});

// Validate checkboxes
$('.required-checkbox').blur(function() {
if (!$(this).is(':checked')) {
$(this)
.addClass('input-error')
.after('<div class="input-error-message">This field must be completed</div>');
}
});
$('.required-checkbox').focus(function() {
$(this)
.removeClass('input-error')
.next('div')
.remove();
});


$("form").submit(function() {
var error = false;

// text inputs
$(this).find(".required").each(function() {
if ($(this).val().length == 0) {
alert("Please complete required fields.");
$(this).focus();
error = true;
return false; // Only exits the “each” loop
}
});

// checkboxes
$(this).find(".required-checkbox").each(function() {
if (!$(this).is(':checked')) {
alert("Please complete required fields.");
$(this).focus();
error = true;
return false; // Only exits the “each” loop
}
});

if (error) {
return false;
}
return true;
});


  
  



});
 


//
//  pop! for jQuery
//  v0.2 requires jQuery v1.2 or later
//  
//  Licensed under the MIT:
//  http://www.opensource.org/licenses/mit-license.php
//  
//  Copyright 2007,2008 SEAOFCLOUDS [http://seaofclouds.com]
//





 

