In html page you can set the bootstrap messages, that can be shown and hide using JavaScript. On alert message put a css class that does not display when the page is loaded and by using the validation rules get the text from text box in JavaScript and shown hide messages as you need.
If name and father name is missing than it shown alert message in red color. If name and father name is present it shows success message in green color.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
function validate() {
var name = document.getElementById("name").value;
var fname = document.getElementById("fname").value;
$("#fname-alert").hide();
$("#name-alert").hide();
$("#success-message").hide();
//var message = "";
if(name.trim() == "") {
//message = "Your name required ";
//document.getElementById("message-name").innerHTML = message;
$("#name-alert").show();
}
if(fname.trim() == "") {
//message = " Father name required ";
//document.getElementById("message-fname").innerHTML = message;
$("#fname-alert").show();
}
if(name.trim() != "" && fname.trim() != "") {
//document.getElementById("message").innerHTML = "Student Information is saved...";
$("#success-message").show();
}
}
</script>
<style>
.alert{
display: none;
padding: 5px;
margin-top: 25px;
border: 1px solid transparent;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="container">
<div class="alert alert-success alert-dismissable" id="success-message">
<p id="message"> Student Information is saved...</p>
</div>
<div class="row-fluid">
<div class="col-sm-12 col-md-12 col-lg-12"><h2>Student Information</h2></div>
</div>
<div class="row-fluid">
<div class="col-sm-4 col-md-4 col-lg-4">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" id="name">
</div>
</div>
<div>
<div class="col-sm-3 col-md-3 col-lg-3">
<div class="alert alert-danger alert-dismissable" id="name-alert">
<p id="message-name">Name is Required</p>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="col-sm-4 col-md-4 col-lg-4">
<div class="form-group">
<label for="fname">Father Name:</label>
<input type="text" class="form-control" id="fname">
</div>
</div>
<div>
<div class="col-sm-3 col-md-3 col-lg-3">
<div class="alert alert-danger alert-dismissable" id="fname-alert">
<p id="message-fname"> Father Name is Required</p>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="row-fluid">
<div class="col-md-12 col-sm-12 col-lg-12 ">
<div class="separator"> </div>
</div>
</div>
<div class="row-fluid">
<div class="col-md-12 col-sm-12 col-lg-12 ">
<input type="button" class="btn" name="btn" value="Validate" onClick="validate()">
</div>
</div>
</div>
</body>
</html>
If name and father name is missing than it shown alert message in red color. If name and father name is present it shows success message in green color.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
function validate() {
var name = document.getElementById("name").value;
var fname = document.getElementById("fname").value;
$("#fname-alert").hide();
$("#name-alert").hide();
$("#success-message").hide();
//var message = "";
if(name.trim() == "") {
//message = "Your name required ";
//document.getElementById("message-name").innerHTML = message;
$("#name-alert").show();
}
if(fname.trim() == "") {
//message = " Father name required ";
//document.getElementById("message-fname").innerHTML = message;
$("#fname-alert").show();
}
if(name.trim() != "" && fname.trim() != "") {
//document.getElementById("message").innerHTML = "Student Information is saved...";
$("#success-message").show();
}
}
</script>
<style>
.alert{
display: none;
padding: 5px;
margin-top: 25px;
border: 1px solid transparent;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="container">
<div class="alert alert-success alert-dismissable" id="success-message">
<p id="message"> Student Information is saved...</p>
</div>
<div class="row-fluid">
<div class="col-sm-12 col-md-12 col-lg-12"><h2>Student Information</h2></div>
</div>
<div class="row-fluid">
<div class="col-sm-4 col-md-4 col-lg-4">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" id="name">
</div>
</div>
<div>
<div class="col-sm-3 col-md-3 col-lg-3">
<div class="alert alert-danger alert-dismissable" id="name-alert">
<p id="message-name">Name is Required</p>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="col-sm-4 col-md-4 col-lg-4">
<div class="form-group">
<label for="fname">Father Name:</label>
<input type="text" class="form-control" id="fname">
</div>
</div>
<div>
<div class="col-sm-3 col-md-3 col-lg-3">
<div class="alert alert-danger alert-dismissable" id="fname-alert">
<p id="message-fname"> Father Name is Required</p>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="row-fluid">
<div class="col-md-12 col-sm-12 col-lg-12 ">
<div class="separator"> </div>
</div>
</div>
<div class="row-fluid">
<div class="col-md-12 col-sm-12 col-lg-12 ">
<input type="button" class="btn" name="btn" value="Validate" onClick="validate()">
</div>
</div>
</div>
</body>
</html>