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

185
Views
how to change required to disable by javascript?

I am doing to change 2nd select tag name by javascript.

this is my HTML

1st select

<select name="bank" id="bank" class="select" onchange="myFunction(event)">
    <option value="Bank Account" a="required">Bank Account</option>
    <option value="UPI" a="hidden">UPI</option>
</select>

2nd Select

<select name="bank1" class="select" id="bank1" required>
    <option disabled selected>Choose Bank Name</option>
    <option value="SBI">SBI</option>
    <option value="PNB" >PNB</option>
</select>

this is my javascript

function myFunction(e) {
    document.getElementById("bank1").name = e.target.a

but i want to change in 2nd select required to hidden

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

0

Do you want to hide the second select box completely?

function myFunction(e) {
    document.getElementById("bank1").classList.add("hidden")
}

CSS

#bank1.hidden {
     display:none;
}
about 4 years ago · Juan Pablo Isaza Report

0

probably you are looking for setAttribute.

document.getElementById("bank1").required = false;

And for style mutation. As @Kokodoko had already written.

document.getElementById("bank1").classList.add("hidden")
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!