javascript - Hide given input types when checkbox is checked -


i have form consisting of input types. when checkbox not checked, want of other input types disappear , reappear when checkbox checked.could me please? here code:

  <form id='sample' action='sample.php' method='post'>   <input type='hidden' name='submitted' id='submitted' value='1'/><br>  <label for='name' >your full name*: </label> <input type='text' name='name' id='name' maxlength="50" /><br>  <label for='email' >email address*:</label> <input type='text' name='email' id='email' maxlength="50" /><br>  <label for='username' >username*:</label> <input type='text' name='username' id='username' maxlength="50" /><br>  <label for='password' >password*:</label>  <input type='password' name='password' id='password' maxlength="50" /><br> <input type="checkbox" name="vehicle" value="bike"> hide all!<br>   <input type='submit' name='submit' value='submit' />  </form>  

$(function(){    $('input[name=vehicle]').on('change', function(){    if(this.checked){    $('#sample').find('input').not(this).hide();  }    else{    $('#sample').find('input').not(this).show();  }    })    })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <form id='sample' action='sample.php' method='post'>    <input type='hidden' name='submitted' id='submitted' value='1'/><br>   <label for='name' >your full name*: </label>  <input type='text' name='name' id='name' maxlength="50" /><br>   <label for='email' >email address*:</label>  <input type='text' name='email' id='email' maxlength="50" /><br>    <label for='username' >username*:</label>  <input type='text' name='username' id='username' maxlength="50" /><br>    <label for='password' >password*:</label>   <input type='password' name='password' id='password' maxlength="50" /><br>  <input type="checkbox" name="vehicle" value="bike"> hide all!<br>    <input type='submit' name='submit' value='submit' />    </form>


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -