Combine forms

by Akram kamal

HTML

<form action="contact.php" method="post">
    <input type="text" name="f_name" required="required" id="f_name" placeholder="Name">
    <input type="text" name="email" required="required" id="email" placeholder="Email">
    <textarea name="message"></textarea>
    <input type="checkbox" name="newsletter">Subscribe to Newsletter
    <fieldset>
        <input type="text" name="n_name" id="n_name">
        <input type="text" name="n_email" id="n_email">
    </fieldset>
    <input type="submit" id="nbutton">
</form>

CSS

input[name="newsletter"]~fieldset{display:none}

input[name="newsletter"]:checked~fieldset{display:block;border:none;}

JavaScript

$(function(){
    $('input[name="newsletter"]').change(function(){
        $(this).next().children().prop("disabled",!this.checked)
    })
})