Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to create nav tab with javascript with validation to move to the next tab

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<ul class="nav nav-tabs" id="myTab" role="tablist">
  <li class="nav-item">
    <a class="nav-link active" id="home-tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" id="profile-tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Profile</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" id="contact-tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Contact</a>
  </li>
</ul>
<div class="tab-content" id="myTabContent">
  <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
    Home Tab Content<br>
    <input type="text" id="homeText" /> Enter some value
  </div>
  <div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">Profile Tab Content</div>
  <div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">Contact Tab Content</div>
</div>
Comment

how to create nav tab with javascript with validation to move to the next tab

$('#myTab a').on('click', function(e) {
  e.preventDefault();
  if (isValid()) {
    $(this).tab('show');
  }
});

function isValid() {
  const text = $("#homeText").val();
  if (text.length === 0) {
    return false;
  }
  return true;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to get state value from history react 
Javascript :: zeamster examples react node 
Javascript :: javascript substring messes emoji 
Javascript :: facebook game files example 
Javascript :: hide url in discord.js 
Javascript :: onclick display array value javascript 
Javascript :: typeorm tosql 
Javascript :: react conditional if localhost 
Javascript :: ar.js getting started 
Javascript :: monk find fields 
Javascript :: console log update status bar 
Javascript :: firebase realtime database query where number bigger 
Javascript :: leaflet draw save event 
Javascript :: react native application architecture 
Javascript :: how to go to settings on next click in react native 
Javascript :: es6 strip child is null from object 
Javascript :: js extract all tags not have attr 
Javascript :: javascript copy array map 
Javascript :: data submit notification in javascript 
Javascript :: site completo com ajax jquery 
Javascript :: get switchery to load after an ajax call 
Javascript :: click and copy jquery dynamic content 
Javascript :: npm smart contract sjon schema 
Javascript :: transaction mode javascript 
Javascript :: return component from react hook 
Javascript :: jlkj 
Javascript :: momen js get time zone code from location name 
Javascript :: fetch an webpage and parse js 
Javascript :: install discord js master 
Javascript :: Load Balance 4 instances of api.js node js 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =