Skip to content

Infragistics Community Forum / Web / Ignite UI for ASP.NET Core / IGgrid Custom validation for Textbox

IGgrid Custom validation for Textbox

New Discussion
Azhar Amin
Azhar Amin asked on Jun 11, 2024 1:48 PM

Hi,
As i am currently working with IGgrid, but the default validation of textbox allows the “spacebar” and enters a blank space even if you don’t add any value in text box and it saves the data even if it is empty.

This is default validation, it accepts blank space before we enter any character, so if i just press spacebar on textbox, it considers that as a value.

setting.ColumnSetting().ColumnKey("CustomerValue").EditorType(ColumnEditorType.Text).Required(true).Validation(true);

 

I need help for setting up custom validation for same, below is the jquery i wrote, it works for textbox but it display the message as alert, i want the message as defualt ie: “This field is required” on top of textbox

var emptyCustomerValue = ui.values.CustomerValue.trim().toLowerCase();
var isEmptySpace = emptyCustomerValue.replace(/^\s+|\s+$/g, "");
if (isEmptySpace === "") {
terminationReasonMappingGrid.showModel(terminationReasonMappingGrid.constants.commonErrorTitle, terminationReasonMappingGrid.constants.emptySpacesNotAllowed);
isClickedOnSave = false;
return false;
}

});

 

The above code displays it in Alert window

Sign In to post a reply

Replies

  • 0
    Riva Ivanova
    Riva Ivanova answered on Aug 23, 2022 6:23 AM

    Hello,

    Thank you for posting into our community!

    I have been looking into your question and an approach I could suggest, in order to apply custom validation using a regular expression and display the message above the field as a popover, is configuring the igGridUpdating’s editorOptions. Furthermore, for the regular expression you could use the igValidator’s pattern option and for displaying the message in a certain position you could configure the notificationOptions option.

    Additionally, in order to demonstrate my suggestion, I have prepared a small sample using the abovementioned approach. In the attached sample, I have configured the editorOptions for the Product Name and Condition columns and when typing whitespaces or not providing a value, different error messages are shown above the field. This could be observed in the below attachment:

    Here could be found my sample for your reference. Please test it on your side and let me know if you need any further assistance regarding this matter.

    In addition, if this is not an accurate demonstration of what you are trying to achieve, please feel free to modify it and send it back to me along with steps to reproduce it.

    Looking forward to your reply.

    Sincerely,
    Riva Ivanova
    Entry Level Software Developer

    • 0
      Azhar Amin
      Azhar Amin answered on Aug 23, 2022 10:18 AM

      Thank you so much.

      • 0
        Riva Ivanova
        Riva Ivanova answered on Aug 23, 2022 12:06 PM

        Hello,

        I am glad that you find my suggestion helpful.

        Thank you for using Infragistics components.

        Regards,
        Riva Ivanova
        Entry Level Software Developer

    • 0
      Mukesh Ahuja
      Mukesh Ahuja answered on Aug 16, 2023 8:45 PM

      really helpful suggestion.

      • 0
        Talk tohannaford
        Talk tohannaford answered on Jun 11, 2024 1:48 PM

        Thank you for such a well written article. It’s full of insightful information and entertaining descriptions. Your point of view is the best among many.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Azhar Amin
Favorites
0
Replies
5
Created On
Jun 11, 2024
Last Post
1 year, 8 months ago

Suggested Discussions

Created by

Created on

Jun 11, 2024 1:48 PM

Last activity on

Feb 23, 2026 7:55 PM