I have this existing function: The checkbox is checked by default and when checkbox is unchecked it will show the ul section
function toggle(className, obj) {
var $input = $(obj);
if ($input.prop('checked'))
$(className).hide();
else $(className).show();
}
<input type="checkbox" id="cb_ship" onclick="toggle('.ship', this)" checked="checked">
<label for="cb_ship" >Same as account name</label>
<form method="post">
<ul class="ship" style="display:none;">
<li> fname <input type="text" name="fname" required></li>
<li> lname <input type="text" name="lname" required></li>
<li> age <input type="text" name="age" required></li>
<li> address <input type="text" name="address" required></li>
<li> city <input type="text" name="city" required></li>
</ul>
<input type="submit" value="send">
</form>
What I want to do: If the checkbox is checked by default, all the required attributes should be disabled without clicking the checkbox. So, I can submit the form.
EDITED: Sorry for the confusion. I updated my question. The submit button must not inside the ul section. So, if checkbox is checked by default and required attributes are disabled (my problem) , I can proceed.