Complete Input Validation
Jquery Code
$(document).ready(function(){
    $('#targets').submit(function() {
      var error=0;

        var name = $('#name').val();
        if(name == ''){
            error = 1;
            alert('Name cannot be empty');
        }


        var country = $('#country').val();
        if(country == '0'){
            error = 1;
            alert('You should select a country.');
        }

        var comment = $('#comment').val();
        if(comment == ''){
            error = 1;
            alert('Comment cannot be empty.');
        }

        if(!($('#checkboxid').is(':checked'))) {
            error = 1
            alert("Please Tick the Agree to Terms of Use");
        }

        if(error){
            return false;
        }else{
            return true;
        }
    });
});
        
HTML Code




Advertise Here

Follow Us On Facebook