FORUMS


Hello There, Guest! Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with initializing array in RSV in jQuery?
#1
I'm using the RSV jQuery plugin, so if this is the incorrect place to post this question, please let me know where I should take this inquiry.

I have a very complicated form involving validation rules that change depending upon which radio button a user selects.

It's all working fine except in the use-case scenario where someone "changes their mind" and clicks a different radio button. The rules change as expected and everything seems to work fine, but there appears to be some "bleed-through" of the validation rules from the earlier radio button selection.

I only noticed this because one of the radio button selections has a larger overall set of rules than the other. When I choose the larger and then change to the smaller, it still validates against the larger's rules.

I'm doing all this with a jQuery bind("change") if/else statement:


PHP Code:
$("[name=submissionType]").bind("change", function() {
        if ($(this).val() == 'Submission_Event') {
            $("#EventInformation").show();
            $("#OWUDailyCalendarForm").RSV({
                displayType"alert-one",
                rules:["required,firstName,Please enter the OWU contact's first name.",
                "required,lastName,Please enter the OWU contact's last name.",
                "custom_alpha,phoneNumber,xxx-xxx-xxxx,Please enter your phone number in the format ###-###-####.",
                "required,emailAddress,Please enter the OWU contact's personal email address.",
                "reg_exp,emailAddress,.*@owu\.edu$,Please enter a valid personal OWU email address.",
                "required,emailAddressForPublication,Please enter an OWU email address for publication.",
                "reg_exp,emailAddressForPublication,.*@owu\.edu$,Please enter a valid OWU email address for publication.",
                "required,OWUSponsoringOrganizationOffice,Please enter the OWU sponsoring organization/office.",
                "required,category,Please select a category for your submission.",
                "required,submissionType,Please select whether your submission is an event or a non-event.",
                "required,eventNameTitle,Please enter the name / title of your event.",
                "required,eventLocation,Please select the location for your event.",
                "required,startDateTime,Please select the start date and time for your event.",
                "required,endDateTime,Please select the end date and time for your event.",
                "required,OWUDailyHeadline,Please enter a headline for your OWU Daily entry.",
                "required,OWUDailyDescription,Please enter a short description for your OWU Daily entry.",
                "required,firstPublicationDate,Please select the first publication date for your OWU Daily entry.",
                "required,roomReservationAcknowledgement\[\],You must acknowledge your room reservation in order to submit this form."
                ]
            });
        }
        else if ($(this).val() == 'Submission_Non-Event') {
            $("#EventInformation").hide();
            $("#OWUDailyCalendarForm").RSV({
                displayType"alert-one",                
                rules
: ["required,firstName,Please enter the OWU contact's first name.",
                "required,lastName,Please enter the OWU contact's last name.",
                "custom_alpha,phoneNumber,xxx-xxx-xxxx,Please enter your phone number in the format ###-###-####.",
                "required,emailAddress,Please enter the OWU contact's personal email address.",
                "reg_exp,emailAddress,.*@owu\.edu$,Please enter a valid personal OWU email address.",
                "required,emailAddressForPublication,Please enter an OWU email address for publication.",
                "reg_exp,emailAddressForPublication,.*@owu\.edu$,Please enter a valid OWU email address for publication.",
                "required,OWUSponsoringOrganizationOffice,Please enter the OWU sponsoring organization/office.",
                "required,category,Please select a category for your submission.",
                "required,submissionType,Please select whether your submission is an event or a non-event.",
                "required,OWUDailyHeadline,Please enter a headline for your OWU Daily entry.",
                "required,OWUDailyDescription,Please enter a short description for your OWU Daily entry.",
                "required,firstPublicationDate,Please select the first publication date for your OWU Daily entry.",
                "required,roomReservationAcknowledgement\[\],You must acknowledge your room reservation in order to submit this form."
                ]
            });
        

Basically, it's evaluating a particular radio button's value and then branching out via if/else to set the RSV instance displayType and rules settings and whatnot. Each branch has all of the validation rules that are needed, so in theory it should work (right?)

After I select the radio button that says it is an event, then the validation rules for event "win" (since they're lengthier?), even if I later change the radio button to be a non-event.

If my hunch about this is correct, then the fix should be for me to clear out the "rules" array somehow, but I've tried a half dozen different standard methods for array-clearing, as well as multiple different positions within the code (beyond the code that's mentioned above), but nothing seems to work.

I thought that RSV would already clear out the rules array when its defined, but apparently that's not the case?

Anyway, if anyone can provide any help with this, it would be greatly appreciated. It's one of those things that nobody noticed for nearly a year (I originally created this form last summer) but now that someone's found it, of course it has cropped up several times for various people.

Doug Thompson
Manager of Web and Electronic Communications
Ohio Wesleyan University
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)