reset form fields when check input is checked
Hi,
When the check input "Create" is checked I want to reset all the form fields. Im using the js below but its not working, do you know why?
- <form method="post" class="clearfix">
- <div class="form-row">
- <div class="form-group col col-lg-6">
- <label for="options">Options</label>
- <div class="form-check">
- <input class="form-check-input" type="radio" name="exampleRadios" id="" value="option1">
- <label class="form-check-label" for="exampleRadios1">
- Option 1
- </label>
- </div>
- <div class="form-check">
- <input class="form-check-input" type="radio" name="create" id="create" checked value="option1">
- <label class="form-check-label" for="exampleRadios1">
- Create
- </label>
- </div>
- </div>
- </div>
- <div class="form-group">
- <label for="name">Name</label>
- <input type="text" required name="name" id="name">
- </div>
- <div class="form-group">
- <label for="description">Description</label>
- <input type="text" class="form-control" value="" name="description" id="description">
- </div>
- <!-- more fields -->
- <input type="submit" class="btn btn-primary btn float-right" value="Store"/>
- </form>
JS:
- <script>
- $('.create').click(function(){
- $('input[type="text"]').val('');
- $('input[type="number"]').val('');
- });
- </script>