There are syntax errors in your code that is why it doesn't work.
You need to place the code inside the spRendered() function:
fd.spRendered(function() {
//your code is here
});
Pay attention to closing brackets. Also, you need to remove double semicolons.
I updated the code and commented out all extra brackets:
fd.spRendered(function() {
function hideOrShowbatteries() {
if (fd.field('battery').value == 'No') {
// Show the batteries field
fd.field('batteries').hidden = false;
// Show the batteriesreordered field
fd.field('batteriesreordered').hidden = false;
} else {
// Hide the batteries field
fd.field('batteries').hidden = true;
// Hide the batteriesreordered field
fd.field('batteriesreordered').hidden = true;
}
}
// Calling hideOrShowbatteries when the battery value changes
fd.field('battery').$on('change', hideOrShowbatteries);
// Calling hideOrShowbattery on form loading
hideOrShowbatteries();
// extra bracket
//}
// extra bracket
//{
function hideOrShowaedpadsexpired() {
if (fd.field('aedpadsexpired').value == 'Yes') {
// Show the padsreplaced field
fd.field('padsreplaced').hidden = false;
// Show the padsrecordered field
fd.field('padsrecordered').hidden = false;
} else {
// Hide the padsreplaced field
fd.field('padsreplaced').hidden = true;
// Hide the padsrecordered field
fd.field('padsrecordered').hidden = true;
}
}
// Calling hideOrShowaedpadsexpired when the battery value changes
fd.field('aedpadsexpired').$on('change', hideOrShowaedpadsexpired);
// Calling hideOrShowaedpadsexpired on form loading
hideOrShowaedpadsexpired();
// extra bracket
//{
});
If the code doesn't work, please check the browser console. You will see the errors that will tell you why the code doesn't work and you will be able to debug it.