How not to trigger RequiredFieldValidator on hidden field (TextBox)

前端 未结 2 976
难免孤独
难免孤独 2020-12-11 10:55

I think this is a common problem. I have a form where I show/hide fields dynamically using jQuery, depending on some radio buttons.

I have RequiredFieldValidator\'s

相关标签:
2条回答
  • 2020-12-11 11:12

    If I remember correctly there's a function called ValidatorEnable(validatorClientId, isEnabled) that allows you to disable/enable the ASP.NET validators via javascript. You could use jQuery right before your form submit to disable all your invisible validators.

    There's some documentation about client side API available from the validators here http://msdn.microsoft.com/en-us/library/aa479045.aspx

    0 讨论(0)
  • 2020-12-11 11:16

    Hey u can set the control to validate property from C# code when u r setting visiblility from C# code.This wil solves ur problem.

    if ($('#input-name').length) {  
           // do something
    
    }
    

    This will now solves ur problem

    0 讨论(0)
提交回复
热议问题