开发者

retain show/hide states upon form validation

In my form I show/hide certain divs based on the radio button s开发者_StackOverflowelection by the user. For example:

$('input[name=\'pick_up_point\']').change(function() {
if($($(this)).val() == 'pick_up_airport')
{
    $('#pick_up_airport_div').slideDown();
    $('#start_point_div').hide();
}
});

Now when the form is submitted, and if there is an error the form is redisplayed. The validation is working fine, except of course the divs are back in their original states. How can I retain the show/hide states?


Onload of the page you could fire the change event for all radio buttons:

$('input[name=\'pick_up_point\']').trigger('change');

This would need to be called after you've defined the change handler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜