Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery.tokeninput required

I have this fantastic little plugin working but I need to require that at least one name be selected. I normally use jquery.validate. However, the validation plugin does not appear to work on a field using the tokeninput. Does anyone have an answer? As always, thanks so much for your help.

$("#NewMessage").validate({          
    rules: {
        name: {
            required: true
        }
    }
}); 
   $("#name").tokenInput("lookup.cfc?method=getNames&returnFormat=json", {
  hintText: "Type in the name of recipient(s)",
  noResultsText: "No results",
  searchingText: "Searching..."
  })
like image 940
Kerrie Avatar asked Feb 22 '23 01:02

Kerrie


1 Answers

I had the same issue and solved it overriding ignore (apparently the problem is that tokenInput hides the original input and by default "validate" doesn't validate hidden inputs)

$("#NewMessage").validate({       
    ignore: "",   
    rules: {
        name: {
            required: true
        }
    }
}); 
like image 189
Laura Avatar answered Feb 27 '23 22:02

Laura