我正在为我的网站使用简单的注册表单。我想在工具提示格式中显示错误。这可能吗?
我尝试了一些解决方案,但它无效。
$(function () {
$('input[name=name]').tooltip({
placement: "right",
container:'#nameDiv',
title: '<?php echo $error_title;?>',
/*trigger: "hover"*/
}).tooltip('show');
});
答案 0 :(得分:0)
答案 1 :(得分:0)
您可以这样做:
<form id="messageForm" class="form-horizontal">
<div class="form-group">
<label class="col-xs-3 control-label">Message</label>
<div class="col-xs-9">
<textarea class="form-control" name="message" rows="5"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-xs-3 control-label">Email address</label>
<div class="col-xs-6">
<input type="text" class="form-control" name="email" />
</div>
</div>
<div class="form-group">
<div class="col-xs-9 col-xs-offset-3">
<button type="submit" class="btn btn-default">Send</button>
</div>
</div>
</form>
<script>
$(document).ready(function() {
$('#messageForm').formValidation({
framework: 'bootstrap',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
message: {
// The messages for this field are shown as usual
validators: {
notEmpty: {
message: 'The message is required'
},
stringLength: {
min: 20,
max: 500,
message: 'The message must be more than 20 and less than 500 characters long'
}
}
},
email: {
// Show the message in a tooltip
err: 'tooltip',
validators: {
notEmpty: {
message: 'The email address is required'
},
emailAddress: {
message: 'The email address is not valid'
}
}
}
}
});
});
</script>
参考链接: Using Bootstrap
上面的例子是使用Bootstrap,你甚至可以使用Jquery / Javascript。