Validation Bugs

18 years 5 days ago #10660 by ravenswood
Validation Bugs was created by ravenswood
Hi,

I've developed a user plugin which carries out some validation on registration and on update.

The validation is working fine, but I am seeing 2 issues which I wondered if anybody else had experienced..

1. When a field is set to required, if it fails to validate correctly then I get my javascript error displayed but the field isn't turned red. I think this is because after the user validation test, there is a builtin check for required fields which sets the background back to normal if the field is present therefore overriding my change.

2. For non-required fields, if I turn the field red because it fails validation, after I input the correct value, the background isn't reset.

See below for an example of my code..

[code:1]$this->_addValidationJS( "\tif (me.value > 100) {\n"
."\t errorMSG += \"".html_entity_decode($error_percar)."\\n\"\n"
."\t me.style.background = \"red\";\n"
."\t iserror=1;\n"
."\t}\n"«»);[/code:1]

Any suggestions gratefully received..

Cheers

John

Please Log in to join the conversation.

18 years 2 days ago #10842 by beat
Replied by beat on topic Re:Validation Bugs
Take a look at the html output and at js validation code of normal CB fields. There is a line you are missing in your code to turn back background to the normal value... ;)

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

17 years 11 months ago #11023 by ravenswood
Replied by ravenswood on topic Re:Validation Bugs
Ah..

I guess you are talking about..

[code:1]else if (me.style.background.slice(0,3)=="red"«»)

me.style.background = cbDefaultFieldBackground;

[/code:1]

I took my code straight from the CB docs, maybe want to update that so that others don't fall into the same trap!

Thanks for the help

Cheers

John

Please Log in to join the conversation.

17 years 11 months ago #11521 by hanna
Replied by hanna on topic Re:Validation Bugs
Hi, Can we get a copy of this Plugin?

Please Log in to join the conversation.

17 years 11 months ago #11524 by ravenswood
Replied by ravenswood on topic Re:Validation Bugs
Hi,

the plugin would be of no use to you as it carries out a very specific function i.e. it validates some extra fields on the registration form. It validates some fields on a new tab which is shown on profile update, it then takes that validated input, performs some calculations and then saves them into some read-only fields..

so all pretty specific (and some of the calculations are trade secrets)

but if anybody has any specific queries I'd be happy to share some of the code here..

Cheers

John

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.635 seconds

Facebook Twitter LinkedIn