<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Simple Registration Form - Enable Submit when all field have data</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" >
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<link rel="stylesheet" href="">
<style type="text/css">
*{
padding: 0;
margin: 0;
}
div fieldset{
margin:
}
</style>
</head>
<body>
<div id="main" class="container">
<div id="RegistrationForm" class="row form-inline ">
<fieldset class="form-group col-md-6 col-sm-6 has-success">
<label for="userName" class="form-control-label col-md-4 col-sm-4 col-lg-4">User Name</label>
<input type="text" id="userName" class="form-control form-control-success col-md-8 col-sm-8 col-lg-8"/>
</fieldset>
<fieldset class="form-group col-md-6 col-sm-6">
<label for="password" class="col-md-4 col-sm-4 col-lg-4">Password</label>
<input type="passsword" id="password" class="form-control col-md-8 col-sm-8 col-lg-8"/>
</fieldset>
<fieldset class="form-group col-md-6 col-sm-6">
<label for="firstName" class="col-md-4 col-sm-4 col-lg-4">First Name</label>
<input type="text" id="firstName" class="form-control col-md-8 col-sm-8 col-lg-8"/>
</fieldset>
<fieldset class="form-group col-md-6 col-sm-6">
<label for="lastName" class="col-md-4 col-sm-4 col-lg-4">Last Name</label>
<input type="text" id="lastName" class="form-control col-md-8 col-sm-8 col-lg-8"/>
</fieldset>
<fieldset class="form-group col-md-6 col-sm-6">
<label for="emailId" class="col-md-4 col-sm-4 col-lg-4">Email Id</label>
<input type="text" id="emailId" class="form-control col-md-8 col-sm-8 col-lg-8"/>
</fieldset>
<fieldset class="form-group col-md-6 col-sm-6">
<label for="confirmPassword" class="col-md-4 col-sm-4 col-lg-4">Confirm Password</label>
<input type="passsword" id="confirmPassword" class="form-control col-md-8 col-sm-8 col-lg-8"/>
</fieldset>
<fieldset class="form-group col-md-6 col-sm-6">
<label for="industry" class="col-md-4 col-sm-4 col-lg-4">industry</label>
<input type="text" id="industry" class="form-control col-md-8 col-sm-8 col-lg-8"/>
</fieldset>
<fieldset class="form-group col-md-6 col-sm-6">
<label for="city" class="col-md-4 col-sm-4 col-lg-4">City</label>
<input type="passsword" id="city" class="form-control col-md-8 col-sm-8 col-lg-8"/>
</fieldset>
<div class="btn-group col-md-11 col-lg-11 col-sm-11 pull-right">
<button class="btn btn-danger ">Cancel</button>
<button id="register" class="btn btn-primary" disabled="disabled">Submit</button>
</div>
</div>
</div>
<script type="text/javascript">
(function() {
$('#RegistrationForm > fieldset > input').keyup(function() {
var isAnyFieldEmpty = false; //assume all field have values
$('#RegistrationForm > fieldset > input').each(function() {
if ($(this).val() == '') {
isAnyFieldEmpty = true; //oh snap got a empty field
}
});
if (isAnyFieldEmpty) {
$('#register').attr('disabled', 'disabled'); //disable submit button
} else {
$('#register').removeAttr('disabled'); //enable submit button
}
});
})()
</script>
</body>
</html>Code snippet for showing how to enable submit button only when all input field have a value in it.