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

265
Views
Validation when button press a * appear in label field

Hi i would like my validation to have an asterisk * when user press the button can it be possible that the label will appear at a label with * and a right a small text on the top left appear saying * is mandatory?

Here my code below

(function() {
  'use strict';
  window.addEventListener('load', function() {
    // Fetch all the forms we want to apply custom Bootstrap validation styles to
    var forms = document.getElementsByClassName('needs-validation');
    // Loop over them and prevent submission
    var validation = Array.prototype.filter.call(forms, function(form) {
      form.addEventListener('submit', function(event) {
        if (form.checkValidity() === false) {
          event.preventDefault();
          event.stopPropagation();
        }
        form.classList.add('was-validated');
      }, false);
    });
  }, false);
})();
<form class="needs-validation" novalidate>
  <div class="form-group row">
    <label for="validationName" class="col-2 col-form-label">Name:</label>
    <div class="col-10">
      <input name="validationName" type="text" class="form-control" id="validationName" placeholder="Company Name" required>
      <div class="invalid-feedback">
        Enter a correct Company Name!
      </div>
    </div>
  </div>

  <div style="left: 1175px; top: 550px;" class="form-group ">
    <button class="btn btn-primary btn-lg float-right" type="submit">Add</button>
  </div>
</form>

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!