Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1845
Ig Validator - Checking if control or form is in a valid state
posted

I'm trying to check to see if a control (or preferably, the entire form, but it doesn't seem like this is possible) is valid, but I'm always getting a "true" result even if the control shouldn't validate.

MVC Helper:

http://pastebin.com/cgj6pDcn

 

Then, I create a view for a IG textbox for a property "Qty" with the following annotations:

[Required]

[DataType("Int")]

[Range(12, 13)]

[Display(Name = "Qty")]

public int Qty { get; set; }

 

BLOCKED SCRIPT

var isValid = ($('#Qty').igValidator('isValidState'));

 

isValid is always true, no matter what's in the Qty textbox.  What am I doing wrong?

Parents Reply
  • 1845
    posted in reply to [Infragistics] Tsvetelina Georgieva

    Ok, I got to the sample at http://samples.infragistics.com/jquery/editors/editors-validation (replaced "local" with "com").

    However, it doesn't really help with my issue.  The sample doesn't use C# data annotations or the "isValidState" method, it instead sets the validation rules using the "ValidatorOptions" method, which cause validation checking on blur, change, and submit.  These work as expected, but can't be used in my case.

    I need to check validation during a partial postback, so the form submit event isn't fired.  This is why I'd like to manually check if the control is in a valid state per it's associated C# property's data annotations, presumably checking the "isValidState" method.

    Will the "IsValidState" method return false if the control is invalid?  If so, is the control considered invalid if it's value doesn't match the C# data annotation for it's associated property?

    In the example I provided, even though my "Qty" property has a "Required" annotation, it's "IsValidState" method always returns true, even if the field is blank.

Children