94 lines
3.8 KiB
HTML
94 lines
3.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>FormValidation demo</title>
|
|
|
|
<link rel="stylesheet" href="../vendor/bootstrap/css/bootstrap.css"/>
|
|
<link rel="stylesheet" href="../dist/css/formValidation.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/formValidation.js"></script>
|
|
<script type="text/javascript" src="../dist/js/framework/bootstrap.js"></script>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-xs-8 col-xs-offset-2">
|
|
<div class="page-header">
|
|
<h1>Ignoring field validator</h1>
|
|
</div>
|
|
|
|
<form id="surveyForm" method="post" action="target.php">
|
|
<div class="form-group">
|
|
<label class="control-label">How do you know about FormValidation?</label>
|
|
<div class="radio">
|
|
<label><input type="radio" name="channel" value="google" /> Google</label>
|
|
</div>
|
|
<div class="radio">
|
|
<label><input type="radio" name="channel" value="github" /> Github</label>
|
|
</div>
|
|
<div class="radio">
|
|
<label><input type="radio" name="channel" value="twitter" /> Twitter</label>
|
|
</div>
|
|
<div class="radio">
|
|
<label><input type="radio" name="channel" value="facebook" /> Facebook</label>
|
|
</div>
|
|
<div class="radio">
|
|
<label><input type="radio" name="channel" value="other" /> Other</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="control-label">Please specify it:</label>
|
|
<input type="text" class="form-control" name="otherChannel" />
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<button type="submit" class="btn btn-primary">Submit</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
$('#surveyForm')
|
|
.formValidation({
|
|
framework: 'bootstrap',
|
|
icon: {
|
|
valid: 'glyphicon glyphicon-ok',
|
|
invalid: 'glyphicon glyphicon-remove',
|
|
validating: 'glyphicon glyphicon-refresh'
|
|
},
|
|
fields: {
|
|
channel: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Please select a channel'
|
|
}
|
|
}
|
|
},
|
|
otherChannel: {
|
|
validators: {
|
|
callback: {
|
|
message: 'Please specific the channel',
|
|
callback: function(value, validator, $field) {
|
|
var channel = $('#surveyForm').find('[name="channel"]:checked').val();
|
|
return (channel === 'other')
|
|
? (value !== '')
|
|
: null; // Ignore if given channel is selected
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
.on('change', '[name="channel"]', function(e) {
|
|
$('#surveyForm').formValidation('revalidateField', 'otherChannel');
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |