Skip to content

Instantly share code, notes, and snippets.

@gonzariosm
Created November 14, 2016 21:11
Show Gist options
  • Save gonzariosm/6a658e883d2c7982e6af1f754f41c551 to your computer and use it in GitHub Desktop.
Save gonzariosm/6a658e883d2c7982e6af1f754f41c551 to your computer and use it in GitHub Desktop.
Validación de Landing Page Instapage
ijQuery(document).ready(function() {
// TRADUCCIONES
_Translate.set( 'Processing...', 'Procesando...' );
_Translate.set( 'Please Fix These Errors', 'Por favor, corregir los siguientes errores' );
_Translate.set( 'is required.', 'es necesario.' );
_Translate.set( 'requires a valid number.', 'solo acepta dígitos.' );
ijQuery.validator.addMethod('rut', function(value, element) {
return this.optional(element) || ijQuery.Rut.validar(value);
}, 'no tiene un formato válido.');
ijQuery.validator.addMethod( 'phonenumber', function( value, element ) {
if( value.length < 8 ) {
return false;
} else {
return true;
}
});
ijQuery.extend( ijQuery.validator.messages, { phonenumber: 'debe tener 8 dígitos.' } );
var label_rut = 'RUT';
var label_phone = 'Celular';
ijQuery( 'form [name="' + base64_encode(label_rut) + '"]' ).Rut({ format_on: 'keyup' });
ijQuery( 'form [name="' + base64_encode(label_rut) + '"]' ).addClass( 'rut' );
ijQuery( 'form [name="' + base64_encode(label_phone) + '"]' ).addClass( 'number' );
ijQuery( 'form [name="' + base64_encode(label_phone) + '"]' ).addClass( 'phonenumber' );
ijQuery( 'form [name="' + base64_encode(label_phone) + '"]' ).attr( 'maxlength', '8' );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment