views:

137

answers:

2

Hi,

I have setup some custom rules for validating a field based on whether an item is selected from a drop down box.

I have 3 values in the drop down

  • Please Select
  • Did Not Show
  • Declined

If the user selects "Did not show" a datepicker appears and they have to enter a valid date If the user selects "decline" another drop down appears and the user has to select a value from it

The problem is that it work in IE8 but not in IE7. Ideas?

I have set this up as follows;

    this.SetupValidations = function() {
            //validations
            LLNP4.validate('#uxReferralAssessmentDetailsForm',
                {
            rules: {
                assessmentDecision: { requiredSelect: "0" },
                NoShowDate: { required: othis.clientDidNotShowValidation },
                DeclinedReason: { requiredSelect: othis.clientDeclinedValidation }
                    }
                });
            }


     this.clientDidNotShowValidation = function() {
            if ($("#uxassessmentDecision option:selected").text().toUpperCase() == "DID NOT SHOW")
            { return true; }
            else
            { return false; }
        }


        this.clientDeclinedValidation = function() {
            if ($("#uxassessmentDecision option:selected").text().toUpperCase() == "DECLINED")
            { return "0"; }
            else
            { return "1"; }
        }


this.ValidateReferralAssessmentSubmission = function() {
        othis.SetupValidations();
        if ($("#uxReferralAssessmentDetailsForm").valid()) {
            return true;
        }
        else {
            return false;
        }
    }


this.OnAssessmentSave = function () {
        //post back to the server and update the assessment details    
        var options = {
            target: '',
            url: '../Referral/UpdateReferralAssessmentDetails',
            data: { ReferralId: referralIdentifier },
            beforeSubmit: othis.ValidateReferralAssessmentSubmission,
            dataType: 'json',
            success: othis.UpdateReferralAssessmentStatus,
            clearForm: true
        };

        $('#uxReferralAssessmentDetailsForm').ajaxSubmit(options);

    }
A: 

Maybe if you insert a ; at end of every function, like this:

this.SetupValidations = function() {
            //validations
            LLNP4.validate('#uxReferralAssessmentDetailsForm',
                {
            rules: {
                assessmentDecision: { requiredSelect: "0" },
                NoShowDate: { required: othis.clientDidNotShowValidation },
                DeclinedReason: { requiredSelect: othis.clientDeclinedValidation }
                    }
                });
            };
TiuTalk
thanks. tried that and it probably good standard. Unfortunately didn't do anything.
kurasa
A: 

There's a typo?

othis.SetupValidations();

Isn't "this" instead "othis"?

TiuTalk
thanks. No I make othis an instance on the constrcutor likefunction referralEdit() { var decision; var othis = this;}
kurasa