Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6223385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:28:51+00:00 2026-05-24T08:28:51+00:00

In colModel I have one custom_func: myFunc() which tests whether an integer value entered

  • 0

In colModel I have one custom_func: myFunc() which tests whether an integer value entered into the text field of the jqGrid native Add or Edit modal form is not already in use in the handful of rows visible in the grid where loadonce:true is set in the options. The way it is the custom_func: is not executed until the modal form Submit button is clicked but I’d like to have the modal form text field tested when it is focusout (or blur?). Is there a way to do this? I’ve tried to do it as showing below in the afterShowForm: option and it kind of works but the error message and halting is not the same as when the Submit button is clicked, is there a way to do focusout/blur from custom_func: myFunc()?

The following shows colModel snippet followed by the custom function followed by my attempt to use focusout in afterFormShow: function() of the Add modal form.

//colModel
...},
{name: 'ezyid', index: 'ezyid', width: 60, align: "center", editable: true,
        formoptions: { rowpos: 1,
            colpos: 1,
            label: "Ezy ID",
            elmprefix: "(*) " 
            },
editrules: {
            custom: true,
            custom_func: chkDuplicateEzyids, //custom function
            required: true
            }
        },             

The colModel custom function:

function chkDuplicateEzyids(value, colname) {

var isFound = false;

var rows = grid.jqGrid('getRowData');

for (var i = 0; i < rows.length; i++) {

    var row = rows[i];

    if (value == row.ezyid && value != '') { isFound = true };

}

if(isFound){

    return [false, "This Ezy ID is in use, please enter another or press Cancel."];

} else {

    return [true, ""];

}

}

My less than ideal attempt to use the custom function accessed from the afterShowForm: option of the Add modal form options (would be similar use in Edit if it had to be done this way):

addSettings = {
recreateForm: true,
jqModal: false,
reloadAfterSubmit: false,
closeOnEscape: true,
closeAfterAdd: true,
afterShowForm: function ($form) {
    var form = $form.parent()[0];

    $("#ezyid", form).blur(function () { //or focusout() if better

        var resp = chkDuplicateEzyids($(this).val(), 'Ezy ID');

        if (!resp[0]) {
            $("#FormError", form).show();
            $(".ui-state-error", form).html(resp[1]);
        }
    });

    $("#lui_" + grid[0].id).hide();
},
onclickSubmit: onclickSubmitLocal
},

To summarize, I’d like to use focusout (or blur) to immediately test the text field value rather than having to enter in all other values of the form to get to the Submit button only to find the value is already in use. This seems a common practice but I cannot figure it out in this context. Many TIA.

( some code snippet(s) reused with by approval and with appreciation to stackoverflow user @Oleg )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:28:52+00:00Added an answer on May 24, 2026 at 8:28 am

    I would recommend you to use dataEvents to bind any event handler (like focusout which is a little better as blur) to the corresponding input control. See the old answer for an example.

    One more remark. The 'ezyid' column seems to have unique values. So you can consider to use key: true in the column. In the case the ids for the grid rows (for the <tr> elements of the <table>) will be used with the values from the column. In the case the chkDuplicateEzyids function can be reduced to the if ($('#' + value).length > 0) {/*duplicate are found*/} or to the if ($('#' + $.jgrid.jqID(value)).length > 0) {/*duplicate are found*/} if you would allows to use meta-characters in the id. The only thing which you need to implement hiding of the 'ezyid' column in the Edit dialog (see here for details) and show it only in the “Add” form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jqGrid with say user information which is to be edited in
I have the following jQuery code which I'm using to populate a jqGrid. It
I have jqGrid with two columns, one being hidden. For some reason in FireFox
Can we include two headers in jqgrid. One with a colModel and one without
I have primary key of my row as hidden field in my jQGrid. It
I have the below code in my jqgrid <script type=text/javascript> jQuery(document).ready(function() { var grid
I have a jqGrid defined as such: $(#tableFeedbackReports).jqGrid({ url: '/FeedbackReports/GetFeedbackReport', datatype: 'json', colNames: ['ColA',
I have a jqGrid script like that: jQuery(document).ready(function() { var startDate = $(#startDate).Val(); jQuery(#sandgrid).jqGrid({
I have a footerrow in my jqGrid where I sum up the values in
I have a list of products on my site. I draw it with jqGrid.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.