FoolProof Validation working in FireFox but not IE

Nov 29, 2011 at 9:07 PM

I am reposting this as I already posted in ASP.Net fourms.
But the responser suggested I contact the developer.

Here is my original Post from: http://forums.asp.net/t/1744638.aspx/1?FoolProof+Validation+working+in+FireFox+but+not+IE

I just added the MVC FoolProof Validation Extensions to my project.

In my model I added a FoolProof Validation Attribute like this:

[DisplayName("Assoc Work Type")]
[RequiredIf("WORKTYPE", "Airport Project")]
public string ASSOC_WORKTYPE { get; set; }

---------------------------------------

So for my RequiredIf validation, WORKTYPE is the dependant property and "Airport Project" is the dependant value for ASSOC_WORKTYPE.

Here is my WORKTYPE property:

 

[DisplayName("Work Type")]
[Required]
public string WORKTYPE { get; set; }

 

---------------------------------------------

I used NuGet to add "MVC FoolProof Validation" to my project.
And then I put a "using Foolproof;" statement at the top of my model.

In my View I have

<div class="editor-field" style="position:relative; top: 10px;">
    @Html.DropDownListFor(model => model.ASSOC_WORKTYPE,new SelectList(new List<string> { "LIGHTS", "RUNWAY", "TAXIWAY", "OTHER" }), "", new { @class = "requiredField"})
    @Html.ValidationMessageFor(model => model.ASSOC_WORKTYPE, "!")
</div>

---------------------------------------------

All of this works perfectly in FireFox.
If I try to submit/insert, the ASSOC WORK TYPE DropDownList gets the validation error style and the Red Exlamation mark (!).
If I select an option, the red ! goes away and so does the val error style  - dynamically- on the client side.
If I click submit the long text desc goes away in my ValidationSummary helper - server side.

In my View, in addition to these script files for normal validation:

 

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<cript src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

 

I've also added:

<script src="@Url.Content("~/Scripts/mvcfoolproof.unobtrusive.min.js")" type="text/javascript"></script>

This one extra script that gets installed with the FoolProof dll is all I needed to get everything working in FireFox.
What do I need to get this working in IE?
All of my other client side validation works in IE.
Even one from DataAnnotationExtensions - Integer.

Can someone please help?

Also here is a link that says to add some other files but they cause errors at least in IE.  Didn't check in FireFox since I got that working with just this one extra script include.
http://foolproof.codeplex.com/

 

 

Coordinator
Nov 30, 2011 at 4:33 PM

Here is a link to a MVC project where I recreated the example above. It seems to work find in IE, Firefox and Chrome. Compare it to your actual project and let me know what you find:

http://dl.dropbox.com/u/73019/MVC%20Required%20If%20Sample.zip

Nov 30, 2011 at 5:10 PM

Thanks - I just tried it.
And I am getting the same results in your version as mine:

Works in FireFox, but not in IE.

In FireFox, selecting the first blank option of no Assoc Work Type kicks off the validation. Great.
Selecting an actual option for Assoc Work Type like "RUNWAY" makes the validation message goes away and you are allowed to submit. Great.

In IE however, when you first get to the page no val message. Correct, of course.  But if you now choose "RUNWAY" and click "Go" to submit , the val error message does not clear and you are still not allowed to submit.
This is the behavior issue I am running to.

Hope all of that makes sense.

Coordinator
Nov 30, 2011 at 5:18 PM
Edited Nov 30, 2011 at 5:19 PM

Yeah, I see it now. It seem to only happen in pre-IE 9. I'll take a look. 

On Wed, Nov 30, 2011 at 11:10 AM, smiller781 <notifications@codeplex.com> wrote:

From: smiller781

Thanks - I just tried it.
And I am getting the same results in your version as mine:

Works in FireFox, but not in IE.

In FireFox, selecting the first blank option of no Assoc Work Type kicks off the validation. Great.
Selecting an actual option for Assoc Work Type like "RUNWAY" makes the validation message goes away and you are allowed to submit. Great.

In IE however, when you first get to the page no val message. Correct, of course. But if you now choose "RUNWAY" and click "Go" to submit , the val error message does not clear and you are still not allowed to submit.
This is the behavior issue I am running to.

Hope all of that makes sense.

Read the full discussion online.

To add a post to this discussion, reply to this email (foolproof@discussions.codeplex.com)

To start a new discussion for this project, email foolproof@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com



--
Nick Riggs

 

Nov 30, 2011 at 5:44 PM
Oh - glad you saw it.
I noticed a jQuery.Validator is null or not an object message in IE Web Dev Tools.
Wonder if that has something to do with it.
And if so, if there is another script file I can bring in to fix it.

Connected by DROID on Verizon Wireless


-----Original message-----
From: nickriggs <notifications@codeplex.com>
To:
smiller781@cox.net
Sent:
Wed, Nov 30, 2011 17:18:53 GMT+00:00
Subject:
Re: FoolProof Validation working in FireFox but not IE [foolproof:281234]

From: nickriggs

Yeah, I see it now. It seem to only have in pre-IE 9.

On Wed, Nov 30, 2011 at 11:10 AM, smiller781 <notifications@codeplex.com> wrote:

From: smiller781

Thanks - I just tried it.
And I am getting the same results in your version as mine:

Works in FireFox, but not in IE.

In FireFox, selecting the first blank option of no Assoc Work Type kicks off the validation. Great.
Selecting an actual option for Assoc Work Type like "RUNWAY" makes the validation message goes away and you are allowed to submit. Great.

In IE however, when you first get to the page no val message. Correct, of course. But if you now choose "RUNWAY" and click "Go" to submit , the val error message does not clear and you are still not allowed to submit.
This is the behavior issue I am running to.

Hope all of that makes sense.

Read the full discussion online.

To add a post to this discussion, reply to this email (foolproof@discussions.codeplex.com)

To start a new discussion for this project, email foolproof@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Nick Riggs
Coordinator
Nov 30, 2011 at 5:44 PM

Okay, I figured it out.

IE 9, like other browser, will report the text of and <option> as the value of the <select> if there is no value provided in the <option> tag. However, pre-IE9 browsers did not do this, they just reported an empty string as the value if no value in the <option> was preset. 

To account for this, always provide your <option> tags with a value. Change your code to look like this and let me know:

        @Html.DropDownListFor(model => model.ASSOC_WORKTYPE, new[]
                                                           {
                                                               new SelectListItem() { Text = "LIGHTS", Value = "LIGHTS" },
                                                               new SelectListItem() { Text = "RUNWAY", Value = "RUNWAY" },
                                                               new SelectListItem() { Text = "TAXIWAY", Value = "TAXIWAY" },
                                                               new SelectListItem() { Text = "OTHER", Value = "OTHER" }
                                                           }, "", new { @class = "requiredField" })

Nov 30, 2011 at 6:06 PM

Awsome, Thanks Nick,

That worked like a charm.

Coordinator
Nov 30, 2011 at 6:45 PM
If you don't mind, can you link this thread in the thread you put over on ASP.NET.

On Wed, Nov 30, 2011 at 12:06 PM, smiller781 <notifications@codeplex.com> wrote:

From: smiller781

Awsome, Thanks Nick,

That worked like a charm.

Read the full discussion online.

To add a post to this discussion, reply to this email (foolproof@discussions.codeplex.com)

To start a new discussion for this project, email foolproof@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Nick Riggs
Nov 30, 2011 at 7:44 PM

Yep, sure thing.

The thread is crosslinked in both directions now.

Dec 5, 2011 at 4:38 PM

Hi Nick

I just tried the actual Insert and I get an error on the server side.

Exception reads:
An unexpected exception was thrown during validation of 'ASSOC_WORKTYPE' when invoking Foolproof.RequiredIfAttribute.IsValid. See the inner exception for details.

Inner Exception reads:
The method or operation is not implemented.

Is there something I need to impliment on the server?
In out-of-the-box validation like [Required] I don't need to do anything.

Am I missing something?

Thanks