Client Side Validation with FoolProof

Jun 17, 2010 at 1:24 PM

Hi,

i downloaded foolproof and incorporated it in my project. while it works great on server side, i m still unable to get validations on client side despite adding js file provided with foolproof project. Furthermore, i have also tried making ModelValidator and registered it in global.asax but to no gain. if anybody can tell me how to enable client validations, i will be grateful

regards

Adeel

Aug 10, 2010 at 4:47 AM

Hi Adeel,

Did you get it working yet? If not, did you make sure to add the "Html.ValidateFor(...)" code to your data entry page?

I hope this helps.

Ken

 

Dec 21, 2010 at 11:44 AM

Sorry to hyjack the thread but it's been over 3 months so i hope you don't mind.

I am having the exact same issue.

		[Required(ErrorMessage = "Please make a selection")]
public bool? First { get; set; }

[RequiredIfTrue("First", ErrorMessage="Please make a selection")]
public bool? Dependent { get; set; }

Using the ViewModel above will result in First to be validated on the client but Dependent to be validated on the server.

I have included:

    <script src="<%: ResolveUrl("~/Scripts/MicrosoftAjax.js")%>" type="text/javascript"></script>
    <script src="<%: ResolveUrl("~/Scripts/MicrosoftMvcAjax.js")%>" type="text/javascript"></script>
    <script src="<%: ResolveUrl("~/Scripts/MicrosoftMvcValidation.js")%>" type="text/javascript"></script>
    <script src="<%: ResolveUrl("~/Scripts/MvcFoolproofValidation.min.js")%>" type="text/javascript"></script>


And have this on my view:
            <table>
                <tr>
                    <td width = "185px">
                        <%: Html.DropDownListFor(model => model.First, Model.YesNo, "-- Please Select --")%>
                        <%: Html.ValidationMessageFor(model => model.First, "*")%>
                    </td>
                </tr>
                <tr>
                    <td width = "185px">
                        <%: Html.DropDownListFor(model => model.Dependent, Model.YesNo, "-- Please Select --")%>
                        <%: Html.ValidationMessageFor(model => model.Dependent, "*")%>
                    </td>
                </tr>
            </table>

Many thanks,
Kohan
Dec 21, 2010 at 12:02 PM

Found the solution in another thread, is to do with an error in the JS file.

see: http://foolproof.codeplex.com/Thread/View.aspx?ThreadId=228726