How to make a condition if option selected value with jquery validate? -


i'm trying way isn't working:

$('#contato').validate({ rules:{     nome:       {required: true, notequal: 'nome'},     email:      {required: true, notequal: 'e-mail'},     telefone:   {required: true},     setor:      {required: true},     if ($('#setor option:selected').val()=='trabalheconosco') {         alert('worked')     }     mensagem:   {required: true, notequal: 'mensagem'} }, ... 

when don't use if condition, works when doesn't.. know how solve problem?

what you're asking unclear. want on condition? change rule? validate other input?

you cannot stick chunk of javascript inside rules option. rules option accept comma separated list of key: value pairs , each key must name of form input validated.

if you're trying change rule, you'd put conditional inside of external change event handler , use .rules() method add/change or remove rule form input.

here's similar answer: https://stackoverflow.com/a/21717771/594235


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -