$(document).ready(function(){

		$("form#two").submit( function () {
			var allInputs = $(":input.required");
			//alert (allInputs.length);
			$("span.errors").text('');
			$(":input.required").each(function (i) {
			//alert(this.name);
			if(trim($(this).val()).length == 0)
			{
				if($(this).attr("type")=="text")
				{
					$(this).css("border","1px solid #ff0000");
					$(this).after(" <span class='errors'><b>Enter details</b></span>");
				}
			}
				
				
		  });
				
			return false;
		});


});

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
