Kendo Ui Form Validation: Use field title in validation message - kendo-ui

I am using Kendo Popup grid and notice that the validation message for all the fields that are set to required appear as "{field} is required". I want to be able to use the "Title" field of the model instaed of the fieldname. Is there an easy way for this?
As per Kendo forum http://demos.kendoui.com/web/validator/index.html : I need to specify the error message individually for all the fields which is not a good solution(IMHO).

Currently this is not supported out of the box. You need to set the validation message via the validationMessage attribute.

Related

fluent ui nortstar FormDropdown make it required field

how can we make the the dropdown in the Nortstar Form as a required field?
is it possible to do so ?
in the Fluent ui Form for the textarea and input component we have required Field so onsubmit it validates the input Form shows to fillout for required fields
https://codesandbox.io/s/zgpqse?module=/example.js
But for dropdown we don't have anything as such. how do we validate the Dropdown with required field?
we can disable the submit button based on hooks but it would be good if we have a required field
https://codesandbox.io/s/cokfqy?module=/example.js

Angular Material conflicting with ReactiveForms

I have a login page that has 2 matInputs(username and password). I added the mat-error element to those to matInputs, so the mat-form-field displays an error message when entering invalid Username. Also, both inputs are part of a reactive form. So they both have the "formControlName" attribute.
The problem is that when I unfocus from one of the input fields(with out typing username or password), the warn color from Angular material triggers as part of the reactive forms validator(username/password should not be empty).
I provided images and I can provide code.
This is regular(Good):
This when entering password(Good):
This when Unfocues/Blur(Bad):
And this when entering invalid inputs(good):
I know that the reactive forms are triggering a validator when left empty(onUnfocus). I am trying to find a way to control that or control the Angular material warning color, so it does not trigger with the left empty validator.
There are different types of field validation and there is also form (submit/login) validation. At a practical level, you want form validation not field validation for not empty/required. By default, field validation (validators used in form controls or the 'required' attribute directive) is activated as soon as the field is 'touched'. So if you make a field 'required' an error will be shown as soon as the user applies and removes focus even without entering a value. Form validation however only takes place when the form is submitted.
You have two options - don't make those fields required and instead check them as part of your submit function and then set errors on the form controls if needed. You'll also need to take care of clearing those errors when the user enters a value or focuses the field.
Or, with reactive forms, you can implement a custom ErrorStateMatcher for those fields so that the 'required' validator will only throw an error if the form is submitted rather than when the field is touched. Turning off 'touched' validation this way is fairly common for this kind of thing - you can just modify the Angular Material example shown here: https://material.angular.io/components/input/overview#changing-when-error-messages-are-shown.

custom validation or custom rule to check unique username for kendo UI grid

I am using MVC architecture with webAPI. I have used kendo grid with Popup edit feature, and when I click on "Add new record" link then a popup appears with the various fields. I want to validate my username field. The validation on username is to check whether the entered username is unique or not. If the username is not unique, then it should raise a validation saying that "Username is not unique". For this purpose, I want to write a custom validation for kendo grid which will call the server side function and return the value as true if the username is not unique to my client side function and raise a validation message. Is there a way by which I can validate my kendo grid by writing custom validation or custom rule.
Kindly help me with this issue.
Regards,
Karthik

ASP.NET MVC 3: client-side validation message sticks around afterward if target field disabled

I have a form that has a field (Field A) that needs to be empty if Option 1 is selected on a dropdown, and is required if Option 2 is selected. I have some javascript that clears and disables the Field A when Option 1 is selected.
I have Simon Ince's RequiredIf attribute applied to Field A in the model, dependant on Option 1, and it works well. That's not the problem.
Here's the sequence of events that does cause a problem:
User has Option 2 selected (so that field A is required) and Field A empty.
User clicks on Save. Validation message appears by field A and in the validation summary. All is well.
User changes to Option 1. Field A becomes disabled.
User clicks on Save. Validation message remains by Field A but does not appear in the Validation Summary.
I conclude from this that the RequiredIf validation is working (and Field A is passing validation), but the old validation message is sticking around. Which I do not want.
All this is client-side, by the way.
If the field isn't disabled, everything works as expected, but I'd like it disabled rather than editable but "required to be empty".
Other than clear out the message SPAN tag through js and jQuery, is there a way to fix this?
Because the validation requirements are changing, you need to cause validation to occur, and then update all of the error messages. Since the issue relates to the change of the selected item on the dropdownlist, add the following:
$("#myDropDown").live("change", function() { // assumes dropdownlist has id of 'myDropDown'
$("form").validate().form(); // form() causes error messages to update
});

Custom error messages in jqgrid

How I can display custom error messages for required field and other validations in jqGrid forms.
You can use attr property of the searchoptions to set additional attributes of the input or select element used in the searching toolbar.
UPDATED: In the comment you explained that you means to customize the validation messages. You can ovewride the valuse from $.jgrid.edit.msg (see grid.locale-en.js or other localization files). For example you can use
$.jgrid.edit.msg.required = "is missing";
If you want to make the message more dynamic you can use custom editrule and build the error message inside of custom_func.

Resources