Hi,
I'm not sure if this specific question has been asked somewhere, I tried to do a search but didn't find anything that have helped. What I'm trying to do is to have a custom validation on a field depending on the content of the other field. First field is a dropdown box with different subscription option. What I'm trying to do is have the email required (and the address field optional) if they selected an email type subscription. If they selected a printed material subscription, I would like the email field optional and the address field to be required. I tried to follow http://www.chronoengine.com/faqs/2656-how-can-i-add-a-custom-client-side-validation.html but somehow, it is not working (It even messed up the validation on the radio button on the form allowing the form to be submitted even without making a selection).
I guess, what I really wanted to do is to have the pop-up tool tip error message on blur and on submit. And while I'm at it, how do I change the label/text of the field on the fly? It doesn't have a name or or id properties on it so I'm not sure how would I change it using javascript.
Thanks
--------
Edit: I forgot to mention, I'm using J2.5.11 and 4.0 RC3.5.2.
--------
Edit2: Just saw this thread http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=89646 and I think we're trying to do the same thing.
I tried the code below but it also didn't work
---------
Edit3: Following the update on the thread I mentioned above, I was able to do what I wanted to do using the code below
Note: ContactUs is the name of the form.
I'm not sure if this specific question has been asked somewhere, I tried to do a search but didn't find anything that have helped. What I'm trying to do is to have a custom validation on a field depending on the content of the other field. First field is a dropdown box with different subscription option. What I'm trying to do is have the email required (and the address field optional) if they selected an email type subscription. If they selected a printed material subscription, I would like the email field optional and the address field to be required. I tried to follow http://www.chronoengine.com/faqs/2656-how-can-i-add-a-custom-client-side-validation.html but somehow, it is not working (It even messed up the validation on the radio button on the form allowing the form to be submitted even without making a selection).
I guess, what I really wanted to do is to have the pop-up tool tip error message on blur and on submit. And while I'm at it, how do I change the label/text of the field on the fly? It doesn't have a name or or id properties on it so I'm not sure how would I change it using javascript.
Thanks
--------
Edit: I forgot to mention, I'm using J2.5.11 and 4.0 RC3.5.2.
--------
Edit2: Just saw this thread http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=89646 and I think we're trying to do the same thing.
I tried the code below but it also didn't work
$("publications").addEvent('change', function(){
var address = $("address_1");
if($("publications").selectedIndex == 1){
address.className = "validate['required']";
};
});
---------
Edit3: Following the update on the thread I mentioned above, I was able to do what I wanted to do using the code below
$("publications").addEvent('change', function(){
var address = $("address_1");
if($("publications").selectedIndex == 1){
makeRequired(address);
}else{
makeOptional(address)
};
});
var req = "validate['required']";
function makeRequired(el){
el.addClass(req);
formCheck_ContactUs.register(el);
}
function makeOptional(el){
el.setProperty('class', '');
formCheck_ContactUs.removeError(el);
formCheck_ContactUs.dispose(el);
}
Note: ContactUs is the name of the form.