When my page is loaded, I want all my unverified fields to be disabled:
<form action="demo_form.asp" method="get">
<input type="checkbox" name="vehicle" value="Bike"> I have a bike<br>
<input type="checkbox" name="vehicle" value="Car" checked> I have a car<br>
<input type="submit" value="Submit">
</form>
I tried it with this code, but it does not work:
$(document).ready(function(){
if($(".test").is(':checked'))
$(".test").attr("disabled", false);
else
$(".test").attr("disabled", true);
});
https://jsfiddle.net/m7ny2Le7/1/
source
share