Hi there...
I have a strongly typed partial view that utilizes attribute based validations on the view model properties. In addition to the data annotation validation I need to make an asynchronous call to the web server to validate some info on the fly. If the response is false (indicating an incorrect value) I just want to display the "validation bubble" that informs the user of an incorrect entry. The true/false value is coming back correctly from the server but it is not raising the validation bubble if false.
<div id="datatovalidate">
<div class="float-left editor-label">
@Html.LabelFor(model => model.ProductCode)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.ProductCode, new { @class = "k-textbox" })
</div>
<div class="clear"></div>
</div>
$('#datatovalidate').kendoValidator({
rules: {
InvalidProdCode: function (input) {
var isValid = true;
if (input.is('[id=ProductCode]')) {
$productCode.val($productCode.val().toUpperCase());
if ($isPidx.prop('checked')) {
$.post('@UrlMaker.ToValidateProductCode()' + $productCode.val(), function (data) {
isValid = data;
});
}
}
return isValid;
}
},
messages: {
InvalidProdCode: "Invalid Product Code"
}
});
I have a strongly typed partial view that utilizes attribute based validations on the view model properties. In addition to the data annotation validation I need to make an asynchronous call to the web server to validate some info on the fly. If the response is false (indicating an incorrect value) I just want to display the "validation bubble" that informs the user of an incorrect entry. The true/false value is coming back correctly from the server but it is not raising the validation bubble if false.
<div id="datatovalidate">
<div class="float-left editor-label">
@Html.LabelFor(model => model.ProductCode)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.ProductCode, new { @class = "k-textbox" })
</div>
<div class="clear"></div>
</div>
$('#datatovalidate').kendoValidator({
rules: {
InvalidProdCode: function (input) {
var isValid = true;
if (input.is('[id=ProductCode]')) {
$productCode.val($productCode.val().toUpperCase());
if ($isPidx.prop('checked')) {
$.post('@UrlMaker.ToValidateProductCode()' + $productCode.val(), function (data) {
isValid = data;
});
}
}
return isValid;
}
},
messages: {
InvalidProdCode: "Invalid Product Code"
}
});