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?
Hello,
I tried your approach using our online sample:
http://samples.infragistics.local/jquery/editors/editors-validation
I worked like expected.
I am not able to see your view from the code snippet.
Are you sure that you have included the needed js and css files?
http://help.infragistics.com/NetAdvantage/jquery/2012.1?page=Infragistics.Web.Mvc~Infragistics.Web.Mvc.NumericEditorModel~ValidatorOptions.html
$.ig.loader({
scriptPath: '/samplesbrowser/samplescommon/jquery/common/js/',
cssPath: '/samplesbrowser/samplescommon/jquery/common/css/',
resources: 'igEditors,igValidator,igShared'
});
Hope this helps
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.
Thanks Tsvetelina. However, the online sample link you provided is broken.
Also, if I've included the entire infragistics.js file, do I still need to use the loader?