Created
November 14, 2016 23:20
-
-
Save gonzariosm/c8628a2a5ca1221704bec5c6dd5ef4bf to your computer and use it in GitHub Desktop.
Validación InstaPage con PlaceHolder Nuevo
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
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 (sólo 8 dígitos. Ej: 88302812)'; | |
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