.label_col{ width:20%; padding:5px; float:left; } .field{ width:75%; padding:5px; float:left; } .error_field{ width:75%; padding:5px; float:left; } .error_msg{ display:none; clear:both; color:#f00; } li{ width:100%; float:left; }
$(document).ready(function(){ $('.reset').click(function() { $('#name_error_msg').html('').parent().hide(); $('#country_error_msg').html('').parent().hide(); $('#comment_error_msg').html('').parent().hide(); $('#checkboxid_error_msg').html('').parent().hide(); }); $('#targets').submit(function() { var error=0; $('#name_error_msg').html('').parent().hide(); $('#country_error_msg').html('').parent().hide(); $('#comment_error_msg').html('').parent().hide(); $('#checkboxid_error_msg').html('').parent().hide(); var name = $('#name').val(); if(name == ''){ error = 1; $('#name_error_msg').html("Name cannot be empty"); $('#name_error_msg').parent().show(); } var country = $('#country').val(); if(country == '0'){ error = 1; $('#country_error_msg').html('You should select a country.'); $('#country_error_msg').parent().show(); } var comment = $('#comment').val(); if(comment == ''){ error = 1; $('#comment_error_msg').html('Comment cannot be empty.'); $('#comment_error_msg').parent().show(); } if(!($('#checkboxid').is(':checked'))) { error = 1; $('#checkboxid_error_msg').html("Please Tick the Agree to Terms of Use."); $('#checkboxid_error_msg').parent().show(); } if(error){ return false; }else{ return true; } }); });
Follow Us On Facebook