jQuery.ketchup

.validation('required', 'Este campo es requerido!', function(form, el, value) {
  var type = el.attr('type').toLowerCase();
  
  if(type == 'checkbox' || type == 'radio') {
    return (el.attr('checked') == true);
  } else {
    return (value.length != 0);
  }
})
//Validacion del email.
.validation('email', 'Debe ser un email valido!', function(form, el, value) {
  return this.isEmail(value);
})
//Valida la contraseņa
.validation('rangelength', 'Debe contener una logitud entre 6 y 10.', function(form, el, value, min, max) {
  return (value.length >= 6 && value.length <= 10);
})
.validation('password', 'El password debe coincidir.', function(form, el, value, min, max) {
  return (value.length >= 6 && value.length <= 10);
})

//Valida el tipo de cuenta
.validation('match', 'Seleccione el tipo de cuenta.', function(form, el, value, word) {
  return (value.length != 0);
})
//Valida el pais
.validation('pmatch', 'Seleccione su pais.', function(form, el, value, word) {
  return (value.length != 0);
})

//Valida el pais
.validation('dmatch', 'Ingrese una direccion.', function(form, el, value, word) {
  return (value.length != 0);
})

//Valida las letras
.validation('name', 'Ingrese un nombre.', function(form, el, value) {
  return (value.length != 0);
})

//Valida textarea
.validation('text', 'Ingresa el texto que deseas enviar.', function(form, el, value) {
  return (value.length != 0);
})

.validation('last', 'Ingrese su apellido.', function(form, el, value) {
  return (value.length != 0);
})

//Valida numeros
.validation('number', 'Deben ser numeros validos.', function(form, el, value) {
  return this.isNumber(value);
})

.validation('temp', 'Seleccione el tipo de empresa.', function(form, el, value, word) {
  return (value.length != 0);
})

.validation('rnc', 'Ingrese su RNC.', function(form, el, value) {
  return (value.length != 0);
})

//Valida la url
.validation('url', 'Debe ser URL valida.', function(form, el, value) {
  return this.isUrl(value);
})

//Valida el campo numero
.validation('no', 'Ingrese un numero de direccion.', function(form, el, value) {
  return (value.length != 0);
})
//Valida el campo ciudad
.validation('city', 'Ingrese una ciudad.', function(form, el, value) {
  return (value.length != 0);
})
//Valida el codigo
.validation('codeimg', 'Ingrese el codigo de la imagen.', function(form, el, value) {
  return (value.length != 0);
})

//Valida el nombre de la empresa
.validation('empresa', 'Ingrese el nombre de la empresa.', function(form, el, value) {
  return (value.length != 0);
})

//Valida el cargo en la empresa
.validation('cargo', 'Cual es su cargo en dicha empresa?', function(form, el, value) {
  return (value.length != 0);
})















.validation('maxlength', 'This field must have a maximal length of {arg1}.', function(form, el, value, max) {
  return (value.length <= +max);
})



.validation('min', 'Must be at least {arg1}.', function(form, el, value, min) {
  return (this.isNumber(value) && +value >= +min);
})

.validation('max', 'Can not be greater than {arg1}.', function(form, el, value, max) {
  return (this.isNumber(value) && +value <= +max);
})

.validation('range', 'Must be between {arg1} and {arg2}.', function(form, el, value, min, max) {
  return (this.isNumber(value) && +value >= +min && +value <= +max);
})



.validation('digits', 'Must be digits.', function(form, el, value) {
  return /^\d+$/.test(value);
})








.validation('contain', 'Must contain {arg1}', function(form, el, value, word) {
  return this.contains(value, word);
})

.validation('date', 'Must be a valid date.', function(form, el, value) {
  return this.isDate(value);
})

.validation('minselect', 'Select at least {arg1} checkboxes.', function(form, el, value, min) {
  return (min <= this.inputsWithName(form, el).filter(':checked').length);
}, function(form, el) {
  this.bindBrothers(form, el);
})

.validation('maxselect', 'Select not more than {arg1} checkboxes.', function(form, el, value, max) {
  return (max >= this.inputsWithName(form, el).filter(':checked').length);
}, function(form, el) {
  this.bindBrothers(form, el);
})

.validation('rangeselect', 'Select between {arg1} and {arg2} checkboxes.', function(form, el, value, min, max) {
  var checked = this.inputsWithName(form, el).filter(':checked').length;
  
  return (min <= checked && max >= checked);
}, function(form, el) {
  this.bindBrothers(form, el);
});
