Forums

Custom validation. At least a field

twifer 12 Feb, 2015
Hi!

I'm sorry but my english is very bad.

I have a problem when I try to validate at least one of 5 fields. I have 5 text box (Facebook, Twitter, GooglePlus, LinkedIn, Skype). I add load JS in Onload section with next code (one function per field):

function checkNoFacebook(elem){

if(elem.val() || jQuery("#Twitter").val() || jQuery("#GooglePlus").val() || jQuery("#LinkedIn").val() || jQuery("#Skype").val()){

return true;

}

return false;

}

function checkNoTwitter(elem){

if(elem.val() || jQuery("#Facebook").val() || jQuery("#GooglePlus").val() || jQuery("#LinkedIn").val() || jQuery("#Skype").val()){

return true;

}

return false;

}

function checkNoGoogle(elem){

if(elem.val() || jQuery("#Twitter").val() || jQuery("#Facebook").val() || jQuery("#LinkedIn").val() || jQuery("#Skype").val()){

return true;

}

return false;

}

function checkNoLinkedin(elem){

if(elem.val() || jQuery("#Twitter").val() || jQuery("#GooglePlus").val() || jQuery("#Facebook").val() || jQuery("#Skype").val()){

return true;

}

return false;

}

function checkNoSkype(elem){

if(elem.val() || jQuery("#Twitter").val() || jQuery("#GooglePlus").val() || jQuery("#LinkedIn").val() || jQuery("#Facebook").val()){

return true;

}

return false;

}

In each field I added in custom function field, the name of de function

When I submit form first time, the validation is ok, but if I insert one field, for example Twitter, the form continue validating other fields

I also try with only one function with same result:

function checkSocial(elem){

if(jQuery("#Facebook").val() || jQuery("#Twitter").val() || jQuery("#GooglePlus").val() || jQuery("#LinkedIn").val() || jQuery("#Skype").val()){

return true;

}

return false;

}

Can i help me?

I'm working in localhost, so I can't send you an access

Thanks in advance
Max_admin 13 Feb, 2015

When I submit form first time, the validation is ok


What does this mean ? you mean an empty form ?

I think one social function should work in this situation, but I didn't try it myself!

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
twifer 13 Feb, 2015
Thanks for your answer.

I want a function that check that one of the fields is inserted, but only works if insert one field first time

This is the procedure:

1. All fields are empty
2. Click on submit button
3. Validation is ok.
4. Insert one social field, for example Twitter.
5. Click on submit button
6. Validation failed. Twitter field ok, but the other fields remain mandatory

I hope you understand me.

thanks in advance
Max_admin 15 Feb, 2015
Ok, but none of your fields should be set to "required", I have just tested this, 2 fields and it works ok:

function one(el){
	if(jQuery("#text3").val() || jQuery("#text5").val()){
		return true;
	}
	return false;
}


Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.