Hi,
I want a field to be shown/hidden and validated depending on a value of a certain dropdown.
I am able to hide/show the field but the validation would not work.
I have added this code in my load JS event. Have i missed something?
I want a field to be shown/hidden and validated depending on a value of a certain dropdown.
I am able to hide/show the field but the validation would not work.
I have added this code in my load JS event. Have i missed something?
window.addEvent('domready', function() {
$('product_interest').addEvent('change', function() {
if($('product_interest').value == 'Loans'){
$('loanspacer').setStyle('display', '');
$('loanrow').setStyle('display', '');
$('comments').addClass("validate['required']");
formCheck.register($('comments'));
}
});
});
formCheck.register($('comments'));
is working since when i replace it with a non existing field it will generate a javascript error.
is working since when i replace it with a non existing field it will generate a javascript error.
Hi elvinjoe ,
That looks OK to me. Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
Bob
That looks OK to me. Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
Bob
Hi elvinjoe,
This works OK on my test site. The only problem is that it comes last in the validation sequence. You can fix this with a second parameter.
I also added code to handle a change of the drop-down and the page reloading:
Bob
This works OK on my test site. The only problem is that it comes last in the validation sequence. You can fix this with a second parameter.
formCheck.register($('comments'), 1);
I also added code to handle a change of the drop-down and the page reloading:
window.addEvent('domready', function() {
$('product_interest').addEvent('change', function() {
if ( $('product_interest').value == 'Loans' ) {
$('loanspacer').setStyle('display', 'table-row');
$('loanrow').setStyle('display', 'table-row');
$('comments').addClass("validate['required']");
formCheck.register($('comments'), 1);
} else {
$('comments').removeClass("validate['required']");
formCheck.dispose($('comments'));
$('loanspacer').setStyle('display', 'none');
$('loanrow').setStyle('display', 'none');
}
});
});
window.addEvent('load', function() {
if ( $('product_interest').value == 'Loans' ) {
$('loanspacer').setStyle('display', 'table-row');
$('loanrow').setStyle('display', 'table-row');
$('comments').addClass("validate['required']");
formCheck.register($('comments'), 1);
}
});
Bob
Wonder if you can help me with similar issue.
on the addEvent, I keep getting the VARNAME is null.
Tried $('#radio5').value as well as $('radio5').value but keep getting "radio5 is null"
Mootools is loaded.
on the addEvent, I keep getting the VARNAME is null.
Tried $('#radio5').value as well as $('radio5').value but keep getting "radio5 is null"
Mootools is loaded.
Bob yes it here, here's the code:
I have some jQuery on this page, I wonder if it is causing a conflict.
Yes
<input type="radio" name="radio5" id="radio50" class="radio" title="" value="Yes"/>
No
<input type="radio" name="radio5" id="radio51" class="radio" title="" value="No"/>
I have some jQuery on this page, I wonder if it is causing a conflict.
Your ids are "radio50" and "radio51", so "radio5" will be null for sure.
Regards,
Max
Regards,
Max
This topic is locked and no more replies can be posted.