i m trying to put a page validator to check if there are records in the subgrid. If there is atleast one record in the subgrid it should progress to the next page otherwise it has to throw error. I have implemented a similar code ina different page and it is working fine. but for a different webform step this code isnt working. Can someone please tell me how we can debug a validator. My code is below
$(document).ready(function () {
if (typeof (Page_Validators) == 'undefined') return;
// Create new validator
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "SchoolPlacementvalidator";
newValidator.controltovalidate = "SchoolPlacement";
newValidator.errormessage = "<a href='#SchoolPlacement'>At least one Qualification item must be added to progress.</a>";
newValidator.evaluationfunction = function () {
var SchoolPlacement = $("#SchoolPlacement table tbody tr").length;
if (SchoolPlacement === 0) {
return false
}
else {
return true;
}
};
Page_Validators.push(newValidator);
});
*This post is locked for comments
Hi edev,
Whenever there are no records on a list there is a message showing that can be the default one or some customized from your size.
Maybe you can work with : contains("no data found"), so finding the presence of a text instead of the table rows.
Something like this:
$(".entity-grid.entitylist").on("loaded", function () { if($('span:contains("your txt")')){ //your logic } });
Hope it helps!
Hi Nicholas, yes it is a javascript code and its a jquery call from client side to the script which resides in app server. I have resolved the issue by a temporary fix by disbaling the button until atleast one record is added to the subgrid.
Sorry, I'm not quite following.
The code you provided is JavaScript, which means it should run client-side (in the browser). Where did you add the code to your Portal? It should be added via the Custom JavaScript field on the Web Form Step.
Once you have it in the right spot, you should be able to find it in your browser's Developer Tools, and then hopefully by putting a breakpoint there, the breakpoint will be hit when you click the submit button.
Nick
Hi Nicholas, it does not give any error and it proceeds to the next page. The problem with my code, we have put the code in app server and calling it in the respective steps and i m not able to debug the code inserting breakpoints. And also i tried to insert an alert and that doesnt work.
Hi,
When you say it doesn't work, does it give an error? Or does it just let you proceed even if there are no rows in the table?
As Mahender suggested, you'll probably need to use Developer Tools (F12) to get to the bottom of it. I'd first put a breakpoint on the [if (SchoolPlacement === 0)] line of code, and make sure it is getting there when you click submit, and if it's giving you the value you'd expect.
Nick
Hi Mahendar, thanks for responding back. I checked on the console already and it is working fine and giving me the right count.
Hi,
I will suggest you to use chrome Developer tools and first check your code is working fine or not under the console
$("#SchoolPlacement table tbody tr").length;
it will help you to troubleshoot.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156