Remove input value if option No is clicked

How can I remove the value once the user click the Yes and input a value on input box but change his mind and click the No option but the input value is still there

<div class="control-group">
    <label class="control-label" for="radios">Do you offer rented call center seating on a monthly basis?</label>
    <div class="controls">
        <label class="radio" for="yes">
            <input type="radio" name="radios-1" id="radios-1" value="Yes">Yes</label>
        <label class="radio" for="no">
            <input type="radio" name="radios-1" id="radios-1" value="No">No</label>
    </div>
</div>
<div class="form-group" style="display:none;" id="seatnumber">
    <label class="control-label" for="name">How many seats do you have available?</label>
    <div class="input-group">   <span class="input-group-addon"><i class="fa fa-user"></i></span>

        <input type="text" class="form-control  input-normal" placeholder="Enter number of seats here..." name="monthly_rental" id="monthly_rental">
    </div>
</div>

JS

        $('input[name|="radios-1"]').change(function() {

        if($(this).val()=='Yes') {
            $('#seatnumber').fadeIn();

        } else {

            $('#seatnumber').fadeOut();
        }
    });

Answers


Try this:

$('input[name|="radios-1"]').change(function() {
        if($(this).val()=='Yes') {
            $('#seatnumber').fadeIn();
        } else {
            $('#seatnumber input').val(''); // remove value when user click No
            $('#seatnumber').fadeOut();
        }
});

DEMO


   $('input[name|="radios-1"]').change(function() {
        $('#monthly_rental').val('');
        if($(this).val()=='Yes') {
            $('#seatnumber').fadeIn();

        } else {

            $('#seatnumber').fadeOut();
        }
    });

Demo:

http://jsfiddle.net/7Te9d/


Need Your Help

How to check if a file exists in a directory in sd card

android file android-sdcard

I want to check whether a given file exists in android sd card. I am trying it out with creating a file using the absolute path and checking with file.exists() but its not working. The URL for the ...

PHP: Is it cleaner to cast to int for calculating?

php types casting type-conversion

I am writing a function that accepts a numeric string as argument, then does some calculations with it and returns it.