prevent Duplicate values using Jquery Validation

前端 未结 11 1906
深忆病人
深忆病人 2020-12-04 22:28

I have form and form text field which generates dynamically using JSP. And I\'m using Jquery validation but want to add functionlaty to prevent duplicate entry in the form.<

11条回答
  •  情书的邮戳
    2020-12-04 23:09

    If I'm not mistaken, you could narrow the duplicate comparison down a bit. For example, I just want to look at other fields of the same class, say 'name':

    $(parentForm.find('.name')).each(function () {
                if ($(this).val() === value) {
                    timeRepeated++;
                }
    

    or maybe:

    $('.name').each(function () {
                if ($(this).val() === value) {
                    timeRepeated++;
                }
    

提交回复
热议问题