151 lines
5.7 KiB
HTML
151 lines
5.7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>BootstrapValidator demo</title>
|
|
|
|
<link rel="stylesheet" href="../vendor/bootstrap/css/bootstrap.css"/>
|
|
<link rel="stylesheet" href="../dist/css/bootstrapValidator.css"/>
|
|
|
|
<script type="text/javascript" src="../vendor/jquery/jquery.min.js"></script>
|
|
<script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script>
|
|
<script type="text/javascript" src="../dist/js/bootstrapValidator.js"></script>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-lg-8 col-lg-offset-2">
|
|
<div class="page-header">
|
|
<h2>Reset form example</h2>
|
|
</div>
|
|
|
|
<form id="defaultForm" method="post" class="form-horizontal" action="target.php">
|
|
<div class="form-group">
|
|
<label class="col-lg-3 control-label">Full name</label>
|
|
<div class="col-lg-4">
|
|
<input type="text" class="form-control" name="firstName" placeholder="First name" />
|
|
</div>
|
|
<div class="col-lg-4">
|
|
<input type="text" class="form-control" name="lastName" placeholder="Last name" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="col-lg-3 control-label">Email address</label>
|
|
<div class="col-lg-5">
|
|
<input type="text" class="form-control" name="email" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="col-lg-3 control-label">Gender</label>
|
|
<div class="col-lg-5">
|
|
<div class="radio">
|
|
<label>
|
|
<input type="radio" name="gender" value="male" /> Male
|
|
</label>
|
|
</div>
|
|
<div class="radio">
|
|
<label>
|
|
<input type="radio" name="gender" value="female" /> Female
|
|
</label>
|
|
</div>
|
|
<div class="radio">
|
|
<label>
|
|
<input type="radio" name="gender" value="other" /> Other
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="col-lg-9 col-lg-offset-3">
|
|
<button type="submit" class="btn btn-primary">Join Us</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- The modal -->
|
|
<div class="modal fade" id="helloModal">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
<h4 class="modal-title">Hello</h4>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="text-center welcome"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
$('#defaultForm')
|
|
.bootstrapValidator({
|
|
feedbackIcons: {
|
|
valid: 'glyphicon glyphicon-ok',
|
|
invalid: 'glyphicon glyphicon-remove',
|
|
validating: 'glyphicon glyphicon-refresh'
|
|
},
|
|
fields: {
|
|
firstName: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'The first name is required and cannot be empty'
|
|
}
|
|
}
|
|
},
|
|
lastName: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'The last name is required and cannot be empty'
|
|
}
|
|
}
|
|
},
|
|
email: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'The email address is required and cannot be empty'
|
|
},
|
|
emailAddress: {
|
|
message: 'The input is not a valid email address'
|
|
}
|
|
}
|
|
},
|
|
gender: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'The gender is required'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
.on('success.form.bv', function(e) {
|
|
// Prevent submit form
|
|
e.preventDefault();
|
|
|
|
var $form = $(e.target),
|
|
validator = $form.data('bootstrapValidator');
|
|
|
|
// Show the modal
|
|
var fullName = [validator.getFieldElements('firstName').val(),
|
|
validator.getFieldElements('lastName').val()].join(' ');
|
|
$('#helloModal')
|
|
.find('.welcome').html('Hello ' + fullName).end()
|
|
.modal('show');
|
|
|
|
$form
|
|
.bootstrapValidator('disableSubmitButtons', false) // Enable the submit buttons
|
|
.bootstrapValidator('resetForm', true); // Reset the form
|
|
});
|
|
});
|
|
|
|
|
|
</script>
|
|
</body>
|
|
</html> |