German Correa
9bb8198f1e
Agrega librerias y temas gráficos de forma local, no cdn, directorio local lib Formulario de registro: - select se hacen con select2, falta validarlos - validación de nombre, apellido y mail ya funcionando con jquery-validate - arregla temas gráficos y de presentación FALTA: - validar los select - validar los radiobutton - TODA LA PUTA LOGICA DE BACK-END DE NUEVO!!!
27 lines
1.0 KiB
JavaScript
27 lines
1.0 KiB
JavaScript
( function() {
|
|
|
|
function stripHtml( value ) {
|
|
|
|
// Remove html tags and space chars
|
|
return value.replace( /<.[^<>]*?>/g, " " ).replace( / | /gi, " " )
|
|
|
|
// Remove punctuation
|
|
.replace( /[.(),;:!?%#$'\"_+=\/\-“”’]*/g, "" );
|
|
}
|
|
|
|
$.validator.addMethod( "maxWords", function( value, element, params ) {
|
|
return this.optional( element ) || stripHtml( value ).match( /\b\w+\b/g ).length <= params;
|
|
}, $.validator.format( "Please enter {0} words or less." ) );
|
|
|
|
$.validator.addMethod( "minWords", function( value, element, params ) {
|
|
return this.optional( element ) || stripHtml( value ).match( /\b\w+\b/g ).length >= params;
|
|
}, $.validator.format( "Please enter at least {0} words." ) );
|
|
|
|
$.validator.addMethod( "rangeWords", function( value, element, params ) {
|
|
var valueStripped = stripHtml( value ),
|
|
regex = /\b\w+\b/g;
|
|
return this.optional( element ) || valueStripped.match( regex ).length >= params[ 0 ] && valueStripped.match( regex ).length <= params[ 1 ];
|
|
}, $.validator.format( "Please enter between {0} and {1} words." ) );
|
|
|
|
}() );
|