Prevent __doPostBack from firing off
<p>I have a grid control that allows users to add a value into the grid.</p>

<p>It produces the following link for inserting a brand new item.</p>

<pre><code>&lt;a onclick="if(!$find('radGridHolidays_ctl00').insertItem()) return false;" id="radGridHolidays_ctl00_ctl02_ctl02_PerformInsertButton" href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("radGridHolidays$ctl00$ctl02$ctl02$PerformInsertButton", "", true, "", "", false, true))'&gt;Insert&lt;/a&gt;
</code></pre>

<p>I have some custom jQuery code that validates textboxes before the submit.  I am trying to prevent the link from submitting the __doPostBack, but my code isn't working.</p>

<pre><code>    // if need be, move this to its own .js file
    String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

    // Document loaded, let's register some validation
    $(function() {

        $('#holidayValidationDisplay').hide();

        $('a#radGridHolidays_ctl00_ctl02_ctl02_PerformInsertButton').click(function(e) {

            e.stopImmediatePropagation();
            e.preventDefault();
            var hasErrors = false;

            // alert('You clicked me!');
            var holidayName = $('#radGridHolidays_ctl00_ctl02_ctl02_validatorHolidayName').val().trim();
            var holidayDate = $('#radGridHolidays_ctl00_ctl02_ctl02_RDIPHolidayDate_dateInput_text').val().trim();

            if (holidayName.length == 0) {
                hasErrors = true;
                $('#holidayList').append('&lt;li&gt;You must provide a holiday name&lt;/li&gt;');
            }

            if (holidayDate.length == 0) {
                hasErrors = true;
                $('#holidayList').append('&lt;li&gt;You must provide a holiday date&lt;/li&gt;');
            }

            if (hasErrors) {
                $('#holidayValidationDisplay').show();
                return false;
            }
        });
    });
</code></pre>

<p>but the link is still firing off when I don't want the postback to occur if there are errors.  I saw something about preventing it to work in an UpdatePanel, but I'm not sure that the solution there applies to my scenario.</p>

<p>If anyone has any ideas, I'm all "ears".</p>
