j query validation with textboxs in asp.net

$(document).ready(function() {
    $('#btnSubmit').click(function(e) {
//btnSubmit is button id 
//For all text boxes        "text"
 var isValid = true;
        $('input[type="text"]').each(function() {
            if ($.trim($(this).val()) == '') {
                isValid = false;
                $(this).css({
                    "border": "1px solid red",
                    "background": "#FFCECE"
                });
            }
            else {
                $(this).css({
                    "border": "",
                    "background": ""
                });
            }
        });
        if (isValid == false) 
            e.preventDefault();
        else 
            alert('Thank you for submitting');
    });
//for all validations are completed or not condition  isvalid

});​

Comments

Popular posts from this blog

Reverse Sentence using c#

How to write Pure java script Program?