Created
March 23, 2011 20:49
-
-
Save aguimaraes/883934 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$.tools.validator.fn("#username", function(input, value) { | |
return value != $('#username').attr('placeholder') ? true : { | |
'pt-br': "Campo obrigatório." | |
}; | |
}); | |
$.tools.validator.fn("#password", function(input, value) { | |
return value != $('#password').attr('placeholder') ? true : { | |
'pt-br': "Campo obrigatório." | |
}; | |
}); | |
$.tools.validator.localize('pt-br', { | |
'*' : 'Valor inválido.', | |
'[required]' : 'Campo obrigatório.' | |
}); | |
$('form').validator({ | |
lang: 'pt-br', | |
position: 'top', | |
offset: [25, 10], | |
messageClass:'form-error', | |
message: '<div><em/></div>' // em é a seta | |
}).submit(function(e){ | |
// se a validação do client passou | |
if (! e.isDefaultPrevented()) { | |
$.ajax({ | |
url: urlbase + 'login', | |
data: $('form').serialize(), | |
type: 'POST', | |
success: function() { | |
add_generic_msg('div.message', 'success', 'Autorizado.'); | |
//redireciona depois de 5 segundos | |
setTimeout(window.location.replace(urlbase + 'dashboard'), 5000); | |
}, | |
error: function(){ | |
add_generic_msg('div.message', 'error', 'Não autorizado.'); | |
} | |
}); | |
e.preventDefault(); | |
} | |
}); | |
}); |
eeduardoantoniopereirasantos
commented
Mar 27, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment