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

120
Views
Restringir usuario para ingresar Mismo rango de valores contra un tipo particular

Tengo una cuadrícula dinámica en la que el usuario puede agregar tantas filas como quiera. Al agregar filas, seleccionará un tipo, y contra ese tipo ingresará un valor mínimo y un valor máximo.

 Type Minimum Value MaximumValue AddRow ABC 12 13 (icon) XYZ 12 13 (icon) ABC 12 13 (icon)

Aquí hay un ejemplo. El usuario selecciona el tipo ABC e ingresa los rangos. En la segunda fila, el usuario ha seleccionado un tipo diferente e ingresa los rangos. En la tercera fila, el usuario ha seleccionado un tipo e ingresa los mismos rangos que en la primera fila. El mismo tipo no puede volver a tener el mismo rango. además, no debe haber superposición también. Entonces, al guardar, quiero hacer algo para restringir que el usuario no ingrese el mismo rango contra ese tipo si ya ha ingresado una vez antes. Estoy confundido como ¿Cómo puedo hacer esto?

Hasta ahora, esto es lo que he hecho para la validación.

 if (map.has(CustomerTypeCode)) { var obj = map.get(CustomerTypeCode); if (minVal >= obj.minVal && maxVal <= obj.maxVal) { alert("Duplicate Ranges Found!"); } } else { map.set(type, { minVal: minVal, maxVal: maxVal }) }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puedes usar Map para lograr lo que quieres.

 //You must declare your map at global scope or outer scope of this operation //so that you don't create new map every time const map = new Map(); let minVal = $(this).find("td:eq(3)").find("input").val(); let maxVal = $(this).find("td:eq(4)").find("input").val(); // I don't know your html so I assume you can get selected type let type = "ABC"; if (map.has(type)) { let obj = map.get(type); if (minVal >= obj.minVal && maxVal <= obj.maxVal) { alert("Duplicate Ranges Found!"); } } else { map.set(type, { minVal: minVal, maxVal: maxVal }) }
about 4 years ago · Juan Pablo Isaza Report
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!