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

337
Views
Seleccionar validación de formulario: ¿averiguar si se ha elegido una opción?

Estoy usando selectize para mis menús desplegables y estoy tratando de hacer una validación de formulario. Cada uno de los menús tiene clase .code_select, y quiero saber si en todos se ha seleccionado alguna opción. Mi código debe determinar si se selecciona algo y, si no, agregar la ID del menú desplegable a una matriz llamada campos_vacíos. Sin embargo, todos mis menús desplegables terminan en la matriz, ya sea que tengan una opción seleccionada o no. Este es mi código:

 $(".code_select").each(function(){ if ($(this).find('option:selected').length === 0) { empty_fields.push($(this).attr("id")+'-selectized'); submitForm=false; } });

Un ejemplo de una de las entradas:

 <div class='col-4'> <input type='text' class='form-control code_select' id='5-tree-Betpap-stdCodeSelect' name='5-tree-Betpap-stdCode' aria-label='Tree Metric Field 5 Standard Code select'> </div>

Y mi selectize inicialización:

 // initialize newCodes selectize control newCodesSelect[index] = $(this).selectize({ valueField: 'id', labelField: 'label', create: false, hideSelected: false, options: listOptions[listType], searchField: 'label', placeholder: "Choose " + listType + " codes (type to search)", maxItems: 1, }); //This stores the selectize object to a variable newCodesSelectize[index] = newCodesSelect[index][0].selectize;

¿Cómo determino si la selección todavía está en el "marcador de posición" cuando mi marcador de posición tiene una variable?

¡Gracias!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

OK, esto es lo que funcionó para mí. Tuve que usar .selectize-control como selector y encontrar si alguno de los elementos tiene data-attribute=null.

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!