Hello,
I want to display a tooltip on my save button when the user hit it and he/she is missing required fields.
In addition I want to add the list of the required fields.
Knowing that it is not a form, the button is calling a jquery function.
Thank you in advance.
<form id="details" role="form">
<table>
<tr>
<td class="info"> User Name:</td>
<td> <ejs-textbox id="firstname" input="change" placeholder="First Name"></ejs-textbox> </td>
</tr>
</table>
</form>
<div>
<ejs-tooltip id="Tooltip" content="User name should not be empty" target="#btn" windowCollision="true" position=TopCenter showTipPointer="true">
<e-content-template>
<ejs-button id="btn" content="Save"></ejs-button>
</e-content-template>
</ejs-tooltip>
</div>
<script>
function change(args) {
var tooltip = document.getElementById('Tooltip').ej2_instances[0];
if (args.value == "") {
tooltip.content = "User name should not be empty";
}
else{
tooltip.content = "Default tooltip";
}
}
</script> |
Thank you Shalini,
The idea is that the tooltip is disabled if the form is complete.
If a user forget to fill one required field and click on the save button the tooltip will be enabled and displays the required fields list (to make it simple).
And the other challenge, I want to make it client side as it is not a form, is is jquery event.
Regards,
<form id="details" role="form">
<table>
<tr>
<td class="info"> User Name:</td>
<td> <ejs-textbox id="firstname" input="namechange" placeholder="First Name"></ejs-textbox> </td>
</tr>
<tr>
<td class="mail">Mail id</td>
<td><ejs-textbox id="mailId" input="mailchange" placeholder="Mail"></ejs-textbox></td>
</tr>
</table>
</form>
<div>
<ejs-tooltip id="Tooltip" content="Please fill the required fields" target="#btn" beforeOpen="beforeOpen" >
<e-content-template>
<ejs-button id="btn" content="Save"></ejs-button>
</e-content-template>
</ejs-tooltip>
</div>
<script>
var boolean,value1,value2;
function namechange(args) {
value1 = args.value; //to get the value of first textbox
}
function mailchange(args) {
value2 = args.value; //to get the value of second textbox
}
function beforeOpen(args) {
if (value1 && value2 ) {
args.cancel = true;
}
}
</script> |