I have some ignite controls put in 2 tabs and I used popover to notify invalid data, I got problem with position of message showing when the tab changed
Is there a simple way to know if control invalid and I can prevent switch tab?
ps: I'm using ignite 15.2
Hello,
I'm glad to hear that you found a solution. If you need further assistance, let me know.
Regards,
Marina Stoyanova
Software Developer,
Infragistics, Inc.
Thank you for your suggestions and I found the event that help me shorter code
var isValid = true; $(document).delegate("#frmTest", "igvalidatorformerror", function (evt, ui) { isValid = false; });
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) { //switch tab
isValid = true;
$("#frmTest").submit();
if (!isValid) {
e.preventDefault();
return false;
}
});
$("#frmTest").submit(function (e) { e.preventDefault(); //prevent default form submit return false; });
Hello Quan,
The other approach is to use the validated event on every editor you have and attach it to a single handler that will check whether the input is valid or not.
var prevent = false;
function editorValidated(evt, ui) {
if (!ui.valid) {
prevent = true;
Then on switch of the tags you can check whether the flag has changed and if yes then cancel the switch event.
if (prevent) {
Please take a look at the provided link and If you have questions let me know.
Best Regards, Marina Stoyanova, Software Developer, Infragistics, Inc.
Thanks for answer me,
But I mean is on a form that have many controls(over 100) with diffrence types such igTextEditor, igDatePicker, igCombo, igNumericEditor ... and the controlid not indexed. So, how can I loop through all controls and call isValid function (I used igEditors control for input valus)
Regards.
Thank you for providing me a sample. What you can do is create a loop on the swap switching event and check whether all of the editors are valid and if not then cancel the event like this:
var tabKey = e.target.hash;
tabKey = tabKey.replace('#', '');
for (var i = 1; i < 21; i++) {
if (!$("#txt" + i).igTextEditor("validator").isValid()) {
Another solution can be using a single validator on multiple fields. You can find more about that approach in our online documentation: http://www.igniteui.com/help/igvalidator-overview#setting-up
Attached you can find a modified version of your sample. If you need further assistance let me know.