Skip to content

Instantly share code, notes, and snippets.

@DfKimera
Created August 25, 2011 19:08
Show Gist options
  • Save DfKimera/1171516 to your computer and use it in GitHub Desktop.
Save DfKimera/1171516 to your computer and use it in GitHub Desktop.
Form validator example
var fields = [
{id: 'input_name', label: 'Nome', mode: 'string', min: 3, max: 128},
{id: 'input_lastName', label: 'Sobrenome', mode: 'string', min: 3, max: 128},
{id: 'input_email', label: 'E-mail', mode: 'string', min: 5, max: 128},
{id: 'input_password', label: 'Senha', mode: 'password', match: 'input_confirmPassword', min: 6},
{id: 'input_birthCity_cityID', label: 'Cidade onde nasceu', mode: 'number', incorrect: 0},
{id: 'input_livingCity_cityID', label: 'Cidade onde vive', mode: 'number', incorrect: 0},
{id: 'recaptcha_response_field', label: 'Palavras de segurança', mode: 'string', min: 1}
];
function doSubmit() {
validate_form(
fields,
function(invalid, error) {
var msg = "Favor preencher corretamente os campos: " + invalid.join(",");
announce(msg, "error");
},
function(fields) {
doRegistration();
//$('#form-registration').submit();
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment