我正在尝试学习qtip jquery插件。我想显示验证失败的字段的qTip。我试过下面的代码但它不起作用。请让我知道我做得对不对。并建议任何使验证变得容易的插件与qTip有关。
HTML 的
<input name="issueNumber" id="issueNumber" label=""
placeholder="Issue number" title="Please enter issue number"></input>
JQuery的
//I used ternary operator
($('#'+namespaceInJs+'issueNumber').val()==null ||
$('#'+namespaceInJs+'issueNumber').val()== '')
?displayQTip():
alert("The value is"+$('#'+namespaceInJs+'issueNumber').val());
的JavaScript
//I have used this function in ternary operator.Calling if validation fails.
function displayQTip(){
alert("IN displayQTip ");
$('#'+namespaceInJs+'issueNumber').qtip({
overwrite: false,
show: {
event: false,
ready: true
},
hide: false,
style: 'cream',
position: {
my: 'left center', // Tool tip arrow place
at: 'right center', // Place of the tool tip to the text box or target item
target: $('#'+namespaceInJs+'issueNumber'),
}
});
}