简体   繁体   中英

Bootstrap input tags apply required validation

I am using bootstrap tags input https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/ and implemented as well successfully. I just want to made it required field so that each user submit form with the technology tags.

<div class="col-lg-6">
 <label class="">Primary Skills (Note: Add comma separated) <span class="text-danger">*</span></label>
 <input class="form-control" type="text" id="primaryskill" name="seeker_primary_skills" required>
 <b class="tooltip tooltip-top-right">This is a required</b>
</div>

Here is the screenshot for this.

在此处输入图片说明

check return on form submit

<form onsubmit="return checktag()">

Javascript/Jquery Code

function checktag(){
   if($("#primaryskill").val() == ''){
      alert("Tags Required"); //Here you can simple alert or change input css with 
      border red with msg with the help of jquery
      return false;
   }else{
        return true; 
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM