I have a form
<form>
Username<br />
<input type="text" id="user_input" name="username" /><br />
Password<br />
<input type="password" id="pass_input" name="password" /><br />
Confirm Password<br />
<input type="password" id="v_pass_input" name="v_password" /><br />
Email<br />
<input type="text" id="email" name="email" /><br /> <br/>
<textarea name="adress" id="adress" ></textarea>
<br>
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female<br>
<input type="submit" id="register" value="Register" disabled="disabled" />
</form>
I want to disable my submit button until all the fields have values.Now everything is okay except radio button.
JS:
<script>
(function() {
$('form > input,textarea,radio').keyup(function() {
var empty = false;
$('form > input,textarea,radio').each(function() {
if ($(this).val() == '') {
empty = true;
}
});
if (empty) {
$('#register').attr('disabled', 'disabled');
} else {
$('#register').removeAttr('disabled');
}
});
})()
</script>
I don't know whether this is good code or not.I am totally new to jquery so please correct me i had make anything wrong. I want to disable my submit button until all the fields have values including radio button..Please help me.Thanks in advance