Skip to Content Skip to Menu

[#7785] How can I validate different fields at Registration?

4 years 11 months ago #315692 by nancy.aharpour
Hi,
I tried your solution but doesn't work...can you tell me where I'm wrong?

This is the scenario:

1) cb_uname1 Text Field
2) cb_uname2 Text Field


in the cb_uname2 Text Field I have the follows values

Tab: Integration >> CB Code Field >> Validation

1) Code Validation = Enable
2) Code:

if (strcmp('[cb_uname1]', '[cb_uname2]')) {
return true;
}else{
return false;
}

3) Ajax Validation = Enable
4) Additional Fields: cb_uname1

thanks
nancy

Attachments:

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
4 years 11 months ago #315700 by krileon
Ensure CB is up to date with the latest build release then replace [cb_uname2] with [value]. That should work fine.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

4 years 11 months ago #315713 by nancy.aharpour
Unfortunately doesn't work :(

this is my code:

if (strcmp('[cb_uname1]','[value]') !== 0) {
return true;
}else{
return false;
}

this always returns true, even if the two fields are the same clearly there is something wrong here --> strcmp('[cb_uname1]','[value]').

I've tried with and without '' I mean --> strcmp('[cb_uname1]','[value]') and --> strcmp([cb_uname1],[value]) neither of them works.

I have

SO= MacOS Catalina 10.15
PHP 7.3.8
Mysql 8.0.17
Joomla 3.9.19
CB 2.4.2+build.2019.12.05.20.13.38.f766ba0fb
CB Code Field 2.0.0+build.2019.12.05.17.48.08.28f23544

What's wrong??? :blink: :unsure:

Thanks
n

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
4 years 11 months ago #315717 by krileon
No idea why you're using strcmp. The below should be sufficient to check that the two values are not the same

Code Validation: Enable
Code (PHP):
Code:
return ( '[value]' != '[cb_uname1]' );
Ajax Validation: Enable
Additional Fields: cb_uname1

That should validate to true if the current fields value does not match the value of the field cb_uname1.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

4 years 11 months ago #315731 by nancy.aharpour
Hi,
I've tried your solution but it doesn't work either, or better it works only in Edit Profile, not during the Registration Process but I need it in the registration process too.

Is it possible?

Thanks
n

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
4 years 11 months ago #315738 by krileon
It should work fine during registration assuming cb_uname1 is also on the registration page otherwise it's just going to be empty. Are both fields accessible on your registration page (the field the validation is on and cb_uname1)?


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum