How to use jQuery to remotely validate a field that depends on another field in the form?

后端 未结 2 1924
夕颜
夕颜 2020-12-08 05:06

I have a form in which I am using remote validation to check if an email address already exists in the database. However, the catch is that on this form, the user can selec

2条回答
  •  忘掉有多难
    2020-12-08 05:24

    From the second example for remote it looks like functions (evaluated during validation) can be used for data, so

    remote: {
        url: 'remote_script.php',
        data: {
            group_id: function () {
                return $('select.group_id').val();
            }
        }
    }
    

    should work.

    For your second question, did you try passing the validation rules to validate()?

提交回复
热议问题