This project is read-only.

Html.ClientSideValidation only validate numeric values

Feb 7, 2010 at 10:09 PM


i am using xval with nhibernate validator with custom provider, jquery 1.4.1 and jquery validate 1.6

when i use Html.ClientSideValidation i get from the model i use only the numeric fields

i tried adding another field with int value, it get it too, but when i changed it to a string, it didnt catch it like the "Filename" and the "Title".

anyone got this problem?

this is the view file

    <%= Html.TextBox("EditFileFormViewModel.Title", (ViewData.Model != null) ? ViewData.Model.Title : "")%>
    <%= Html.ValidationMessage("EditFileFormViewModel.Title") %>
    <label for="EditFileFormViewModel_Filename">
    <%= Html.TextBox("EditFileFormViewModel.Filename", (ViewData.Model != null) ? ViewData.Model.Filename : "")%>
    <%= Html.ValidationMessage("EditFileFormViewModel.Filename")%>
    <%= Html.ClientSideValidation<EditFileFormViewModel>("EditFileFormViewModel")%>

this is my model

public class EditFileFormViewModel
        public virtual int Id { get; set; }
        [NotNull(Message = "*")]
        [NotEmpty(Message = "*")]
        public virtual string Filename { get; set; }

        [NotNull(Message = "*")]
        [NotEmpty(Message = "*")]
        public virtual string Title { get; set; }

Feb 8, 2010 at 11:02 AM

Hi Parnar

When you call Html.ClientSideValidation(), do you specifiy the prefix "EditFileFormViewModel"? If not, this could be your problem.

If you're already doing this, I'm not sure what the problem is. If you've written a custom rules provider, it may be that you're not mapping things to xVal rules in the correct way. Can you post a small demo project that reproduces your problem?