@@ -36,10 +36,12 @@ $.fn.smkValidate = function(options) {
36
36
textEmpty : 'Campo requerido' ,
37
37
// Mensaje de error para el input email
38
38
textEmail : 'Ingresa una cuenta de correo válida' ,
39
- // Mensaje de error para el input number
40
- textNumber : 'Solo se admiten números' ,
41
39
// Mensaje de error para el input alphanumeric
42
40
textAlphanumeric : 'Solo se admiten números y/o letras' ,
41
+ // Mensaje de error para el input number
42
+ textNumber : 'Solo se admiten números' ,
43
+ // Mensaje de error para el input decimal
44
+ textDecimal : 'Solo se admiten números decimales' ,
43
45
// Mensaje de error para el input currency
44
46
textCurrency : 'Ingresa una cantidad monetaria válida' ,
45
47
// Mensaje de error para el input select
@@ -187,10 +189,24 @@ $.fn.smkValidate = function(options) {
187
189
}
188
190
}
189
191
192
+ // Se valida el input ALPHANUMERIC
193
+ if ( smkType === 'alphanumeric' ) {
194
+ // Se crea la expresión regular para el input alphanumeric
195
+ var alphanumericRegex = / ^ [ a - z 0 - 9 ] + $ / i;
196
+ // Se valida que el value del input cumpla con la expresión regular
197
+ if ( ! alphanumericRegex . test ( value ) ) {
198
+ // Se agrega el mensaje de error
199
+ result = $ . smkAddError ( self , languaje [ settings . lang ] . textAlphanumeric ) ;
200
+ return false ;
201
+ } else {
202
+ result = true ;
203
+ }
204
+ }
205
+
190
206
// Se valida el input NUMBER
191
207
if ( smkType === 'number' ) {
192
208
// Se crea la expresión regular para el input number
193
- var numberRegex = / ^ ( [ 0 - 9 ] ) * $ / ;
209
+ var numberRegex = / ^ \d + $ / ;
194
210
// Se valida que el value del input cumpla con la expresión regular
195
211
if ( ! numberRegex . test ( value ) ) {
196
212
// Se agrega el mensaje de error
@@ -201,14 +217,14 @@ $.fn.smkValidate = function(options) {
201
217
}
202
218
}
203
219
204
- // Se valida el input ALPHANUMERIC
205
- if ( smkType === 'alphanumeric ' ) {
206
- // Se crea la expresión regular para el input alphanumeric
207
- var alphanumericRegex = / ^ [ a - z 0 - 9 ] + $ / i ;
220
+ // Se valida el input DECIMAL
221
+ if ( smkType === 'decimal ' ) {
222
+ // Se crea la expresión regular para el input decimal
223
+ var decimalRegex = / ^ \d + (?: \. \d { 1 , 4 } ) ? $ / ;
208
224
// Se valida que el value del input cumpla con la expresión regular
209
- if ( ! alphanumericRegex . test ( value ) ) {
225
+ if ( ! decimalRegex . test ( value ) ) {
210
226
// Se agrega el mensaje de error
211
- result = $ . smkAddError ( self , languaje [ settings . lang ] . textAlphanumeric ) ;
227
+ result = $ . smkAddError ( self , languaje [ settings . lang ] . textDecimal ) ;
212
228
return false ;
213
229
} else {
214
230
result = true ;
@@ -220,7 +236,7 @@ $.fn.smkValidate = function(options) {
220
236
// Se crea la expresión regular para el input currency con $ al inicio
221
237
//var currencyRegex = /^\$?(?:\d+|\d{1,3}(?:,\d{3})*)(?:\.\d{1,2}){0,1}$/;
222
238
// Se crea la expresión regular para el input currency
223
- var currencyRegex = / ^ (?: \d + | \d { 1 , 3 } (?: , \d { 3 } ) * ) (?: \. \d { 1 , 2 } ) { 0 , 1 } $ / ;
239
+ var currencyRegex = / ^ (?: \d + | \d { 1 , 3 } (?: , \d { 3 } ) * ) (?: \. \d { 1 , 4 } ) { 0 , 1 } $ / ;
224
240
// Se valida que el value del input cumpla con la expresión regular
225
241
if ( ! currencyRegex . test ( value ) ) {
226
242
// Se agrega el mensaje de error
@@ -658,6 +674,25 @@ $.smkConfirm = function(options, callback) {
658
674
659
675
660
676
677
+ /*
678
+ |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
679
+ | Float
680
+ |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
681
+ */
682
+ $ . smkFloat = function ( number ) {
683
+ var num = number . replace ( ',' , '' ) ;
684
+ return parseFloat ( num ) ;
685
+ } ;
686
+ /*
687
+ |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
688
+ | Usage
689
+ | var float = $.smkFloat('1,0000.00');
690
+ |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
691
+ */
692
+
693
+
694
+
695
+
661
696
662
697
/*
663
698
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0 commit comments