Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
tratando de convertir una función de validación personalizada para agregar el complemento de validación jquery de validación

Tengo este código de un código diferente en el que estoy tratando de averiguar cómo puedo agregar este código como método adicional de trabajo para mi validador jquery

 $.addMethod('allowing',{ validatorFunction: function (val, $el, conf) { if (val !== '') { var allowing = $el.valAttr('allowing') || '', decimalSeparator = $el.valAttr('decimal-separator') || conf.decimalSeparator, allowsRange = false, begin, end, steps = $el.valAttr('step') || '', allowsSteps = false, sanitize = $el.attr('data-sanitize') || '', isFormattedWithNumeral = sanitize.match(/(^|[\s])numberFormat([\s]|$)/i); if (isFormattedWithNumeral) { if (!window.numeral) { throw new ReferenceError('The data-sanitize value numberFormat cannot be used without the numeral' + ' library. Please see Data Validation in http://www.formvalidator.net for more information.'); } //Unformat input first, then convert back to String if (val.length) { val = String(numeral().unformat(val)); } } if (allowing.indexOf('number') === -1) { allowing += ',number'; } if (allowing.indexOf('negative') === -1 && val.indexOf('-') === 0) { return false; } if (allowing.indexOf('range') > -1) { begin = parseFloat(allowing.substring(allowing.indexOf('[') + 1, allowing.indexOf(';'))); end = parseFloat(allowing.substring(allowing.indexOf(';') + 1, allowing.indexOf(']'))); allowsRange = true; } if (steps !== '') { allowsSteps = true; } if (decimalSeparator === ',') { if (val.indexOf('.') > -1) { return false; } // Fix for checking range with floats using , val = val.replace(',', '.'); } if (val.replace(/[0-9-]/g, '') === '' && (!allowsRange || (val >= begin && val <= end)) && (!allowsSteps || (val % steps === 0))) { return true; } if (allowing.indexOf('float') > -1 && val.match(new RegExp('^([0-9-]+)\\.([0-9]+)$')) !== null && (!allowsRange || (val >= begin && val <= end)) && (!allowsSteps || (val % steps === 0))) { return true; } } return false; }, errorMessage: '', errorMessageKey: 'badInt' });

pero esta función parece estar fallando en todos los extremos

por favor guía

¿Necesito seguir algo en esto o necesito reformatear toda esta función para solucionarlo?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!