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 6898343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:17:02+00:00 2026-05-27T07:17:02+00:00

I’m using a custom function to validate my jqgrid. The users wish to enter

  • 0

I’m using a custom function to validate my jqgrid. The users wish to enter hours worked in a day as Hour:Minute format (e.g., 7:30, 8:00). The validation rule needs to return false whenever a work day exceeds 20 hours and 1 minute. The validation function works in that it flags the error, but firebug displays a 2nd error: b(":input:visible", a.w)[0] is undefined, and points to line 379 in the library (version 4.1.2).

Help is appreciated!

Here’s the grid and the custom validation:

 WorkSchedule.prototype.init = function() {
    var self = this;
    self.jqgridParms = {
        datatype: "local",
        height: 'auto',
        width: 700,
        colNames: ["Week", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Total"],
        colModel: [// very much dummy stuff here.
                    {name: "Week", index: "Week", width: 50, editable: false },
                   { name: "Sun", index: "Sun", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
                       dataInit: function(elem) {
                           $(elem).mask("99:99");
                       }
                   }, align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
                   },
                    { name: "Mon", index: "Mon", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
                        dataInit: function(elem) {
                            $(elem).mask("99:99");
                        }
                    }, align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
                    },
                    { name: "Tues", index: "Tues", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
                        dataInit: function(elem) {
                            $(elem).mask("99:99");
                        }
                    },
                        align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
                    },
                    { name: "Wed", index: "Wed", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
                        dataInit: function(elem) {
                            $(elem).mask("99:99");
                        }
                    },
                        align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
                    },
                    { name: "Thurs", index: "Thurs", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
                        dataInit: function(elem) {
                            $(elem).mask("99:99");
                        }
                    },
                        align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
                    },
                    { name: "Fri", index: "Fri", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
                        dataInit: function(elem) {
                            $(elem).mask("99:99");
                        }
                    },
                        align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
                    },
                    { name: "Sat", index: "Sat", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
                        dataInit: function(elem) {
                            $(elem).mask("99:99");
                        }
                    },
                        align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
                    },
                    { name: "WeekTotal", index: "WeekTotal", width: 55, editable: true, align: "center" }
                  ],
        multiselect: false,
        caption: "Manage Work Schedule",
        rowNum: 10,
        cellEdit: true,
        gridComplete: function() {
            calculateTotal();
        },
        beforeSaveCell: function(rowid, cellname, value, iRow, iCol) {
            formatFromMask(rowid, cellname, value, iRow, iCol);
        },
        afterSaveCell: function() {
            calculateTotal();
        },
        cellsubmit: "clientArray"
    }
}




function validHourEntry(value, colname) {
    var editSuccess = true;

    var errorMsg = "";

    if (typeof value === "undefined") {
        editSuccess = false;
        errorMsg = colname + " entry is required";
    }
    else if (value.length == 0) {
        editSuccess = false;
        errorMsg = colname + " entry is required";
    }

    else {
    value = value.replace(/_/g, "0");   
        var hourMinSplit = value.lastIndexOf(":");
        var hours = value.substring(0, hourMinSplit);
        var mins = value.substring(hourMinSplit + 1, value.length);
        if (isNaN(hours)) {
            editSuccess = false;
            errorMsg = "The value for hours must be numeric";
        }   
        else if (isNaN(mins)) {
            editSuccess = false;
            errorMsg = "The value for minutes must be numeric";
        }
        else if (Number(hours) * 60 + Number(mins) > 1200) {
            editSuccess = false;
            errorMsg = "Work day entry must not exceed 20 hours and 00 minutes";
        }
    }
    return [editSuccess, errorMsg];
}

function createWorkScheduleData(rowID) {

    if (rowID == 0) {
        return [ //goofy dummy data so I can test.
                {Week: "Week 1", Sun: "00:00", Mon: "00:00", Tues: "00:00", Wed: "00:00", Thurs: "00:00", Fri: "00:00", Sat: "00:00" },
                { Week: "Week 2", Sun: "00:00", Mon: "00:00", Tues: "00:00", Wed: "00:00", Thurs: "00:00", Fri: "00:00", Sat: "00:00"}];
    }
    else if (rowID == 1) {
        return [{ Week: "Week 1", Sun: "00:00", Mon: "08:00", Tues: "08:00", Wed: "08:00", Thurs: "08:00", Fri: "08:00", Sat: "00:00" },
    {
        Week: "Week 2", Sun: "00:00", Mon: "08:00", Tues: "08:00", Wed: "08:00", Thurs: "08:00", Fri: "08:00", Sat: "00:00"
    }
    ];
    }
    else if (rowID == 2) {
        return [{ Week: "Week 1", Sun: "00:00", Mon: "04:00", Tues: "04:00", Wed: "04:00", Thurs: "04:00", Fri: "04:00", Sat: "00:00" },
    {
        Week: "Week 2", Sun: "00:00", Mon: "04:00", Tues: "04:00", Wed: "04:00", Thurs: "04:00", Fri: "04:00", Sat: "00:00"
    }
    ];
    }
    else if (rowID == 3) {
        return [{ Week: "Week 1", Sun: "00:00", Mon: "07:30", Tues: "07:30", Wed: "07:30", Thurs: "07:30", Fri: "07:30", Sat: "00:00" },
    {
        Week: "Week 2", Sun: "00:00", Mon: "07:30", Tues: "07:30", Wed: "07:30", Thurs: "07:30", Fri: "07:30", Sat: "00:00"
    }
    ];
    }
}
  • 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-27T07:17:03+00:00Added an answer on May 27, 2026 at 7:17 am

    This turns out to be an issue with Firebug, not with jqgrid. I’m posting this in case others get the same behavior. I turned off Firebug and my validation worked as expected. It also works with chrome and IE without any javascript errors. Annoyed I didn’t think of trying it before posting the question, but happy it’s not a real issue.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am reading a book about Javascript and jQuery and using one of the

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.