jQuery dynamic validation

前端 未结 4 449
野的像风
野的像风 2021-01-22 09:10

Hi there Im trying to do a few things with jQuery validation plugin and seems stuck on one place.

Here is some code:



        
4条回答
  •  面向向阳花
    2021-01-22 09:55

    Try adding the rules first and then calling $('#myform').validate()

    It will not work. You have to call validate method first.

    Using input names approach

    I know i can do it using names as you mentioned above. But unfortunately i will have to use ids.

    content will not be constant. It will vary depending on some rules. So as a result almost each time i will have a different page. There are will be many controls with different ids. many validation groups etc.

    So using "names approach" just doesnt meet my requirements.

    Any thoughts how to use $(selector).rules('add') approach??

    P.S. I've found following example http://www.coldfusionjedi.com/index.cfm/2009/2/22/Using-jQuery-to-add-form-fields--with-validation and it works pretty nice and there is nothing special in code.

提交回复
热议问题