Required form field in Bootstrap
home
Run
screen_rotation
fullscreen
cloud_download
<html> <head> <title>Bootstrap Form Field Validation</title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <!-- Latest compiled and minified JavaScript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> <script type='text/javascript'> function validate(el){ if($(el).val() == ''){ $(el).parent('div').addClass('has-error'); }else{ $(el).parent('div').removeClass('has-error'); } } </script> </head> <body> <div class="container"> <div class="row" style="margin:50px;"> <div class="col-sm-12"> <form role="form"> <div class="form-group has-error"> <label for="email">Email</label> <input type="text" name="email" class="form-control" onkeyup='validate(this);' id="email" placeholder="Enter email"> </div> </form> </div> </div> </div> </body> </html>
<html> <head> <title>Bootstrap Form Field Validation</title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <!-- Latest compiled and minified JavaScript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> <script type='text/javascript'> function validate(el){ if($(el).val() == ''){ $(el).parent('div').addClass('has-error'); }else{ $(el).parent('div').removeClass('has-error'); } } </script> </head> <body> <div class="container"> <div class="row" style="margin:50px;"> <div class="col-sm-12"> <form role="form"> <div class="form-group has-error"> <label for="email">Email</label> <input type="text" name="email" class="form-control" onkeyup='validate(this);' id="email" placeholder="Enter email"> </div> </form> </div> </div> </div> </body> </html>
Copyrights@tutorialsplane.com