I have a Dojo form and i would like to return errors to the form and display them in tool tips since i do not want to add extra elements to my form layout. On researching i saw Dojo doesn't allow for such implementation out of the box since the tool tip will only be displayed in items in focus. In my case i would like tool tips to be displayed for multiple items e.g for all null fields.
I came across a blog where a guy did a hack however i am not sure about his implementation of such. I would like to display multiple tool tips for multiple items. Here is also a fiddle of what i have done thus far. The tooltip only shows for the last item.
Dojo Form
<body class="claro">
<input data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="
regExp: '[\\w]+',
required: true,
invalidMessage: 'First Name Required !'" id="fnameTextBox" title="First Name" placeholder="Your First Name" />
<input data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="
regExp: '[\\w]+',
required: true,
invalidMessage: 'Last Name Required !'" id="lnameTextBox" title="Last Name" placeholder="Your Last Name" />
<button id="validateFields" data-dojo-type="dijit/form/Button">Validate</button>
</body>
Javascript
dojo.require("dijit/form/Button");
dojo.require("dijit/form/ValidationTextBox");
dojo.require("dijit/Tooltip");
dojo.ready(function () {
var fName = dijit.byId("fnameTextBox");
var lName = dijit.byId("lnameTextBox");
dojo.connect(dijit.byId("validateFields"), "onClick", function () {
dijit.showTooltip(
fName.get('invalidMessage'),
fName.domNode,
fName.get('tooltipPosition'), !fName.isLeftToRight());
dijit.showTooltip(
lName.get('invalidMessage'),
lName.domNode,
lName.get('tooltipPosition'), !lName.isLeftToRight());
});
});