Regra NotEqual (Diferente) - Jquery Validation
Enviado por admin, seg, 30/05/2011 - 11:04
Para configuar uma regra NotEqual (Diferente) no Jquery Validation, é necessário criar uma função onde é adicionado um novo método ao Plugin.
Exemplo da função:
jQuery.validator.addMethod("notEqual", function(value, element, param) { return this.optional(element) || value != param;}, "Please specify a different (non-default) value");
Após inserir o nóvo método, basta incluir a regra no JQuery Validation. Exemplo:
rules:{ Campo:{ required: true, notEqual: 0 }},messages:{ Campo:{ required: "Campo [cUF] obrigatório", notEqual: "Informe um [cUf] válido" }}
OBS.: Não foi abordado nesta DICA, como trabalhar com o JQUERY VALIDATION. Assim como incluir as bibliotecas. Acredita-se que já tenha o plugin funcionando.
FONTE: http://stackoverflow.com/questions/3571347/how-to-add-a-not-equal-to-rul...
Tags:


Comentários
Her travelers just about all considered her proform power 995 charming, to start with, and fat plus independent and also loving by nature. I was taken from the court, not the cloister, to replenish this station; from the palace of Caesar, not the class of the Saviour. That man's pages said to the gentleman's girlfriend and also that man's daddy throughout the boy's absences from Macon are indication that that man was at this time forming gradually in that subtle appreciation of nature which was later on to move such a beneficial bit in this fellow's poetry.
Como faço para comparar com mais de um valor exemplo:
nomecampo: {
required: true,
notEqual:"nome", "Nome", "email"
}
Comentar