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

  • Home
  • SEARCH
  • 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 3496288
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:13:48+00:00 2026-05-18T12:13:48+00:00

I want to retrieve from a dataEvents event the value the user entered. I

  • 0

I want to retrieve from a dataEvents event the value the user entered. I want to only allow the numbers 0-24 and if the user inserts a number like 4,5 (german writing) I want to replace the “,” with a “.”. Thus convert “4,5” to “4.5”.

But I’m struggling with getting the data the user entered. The method I’m using always returns blank.

colModel:[
    {name:'sum',index:'sum', width:45, editable: true, sortable:false,
     editoptions: { dataEvents: [ 
                        {
                            type: 'keypress', // keydown
                            fn: function(e) {
                                // console.log('keypress');
                                var v=$(e.target).text();
                                alert(v); // v is empty.
                                //reset the target value, actually I want to replace
                                // enter code here a comma with a point
                                // only allow the numbers 0 - 24
                            }
                        }
                    ] 
                  }
    },
],
  • 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-18T12:13:48+00:00Added an answer on May 18, 2026 at 12:13 pm

    You can do replacement of ‘,’ to ‘.’ better inside of ‘keyup’ event handler with the following

    $(this).val($(this).val().replace(/,/,'.'));
    

    So you can use following dataEvents

    dataEvents: [
        {
            type: 'keyup',
            fn: function(e) {
                var oldVal = $(this).val();
                var newVal = oldVal.replace(/,/,'.');
                if (oldVal !== newVal) {
                    $(this).val(newVal);
                }
            }
        },
        {
            type: 'keypress',
            fn: function(e) {
                var key = e.charCode || e.keyCode; // to support all browsers
                if((key < 48 || key > 57) &&   // if non digit
                   key !== 46 && key !== 44 && key !== 8 && // and not . or , or backspace
                   key !== 37 && key !== 39) { // arrow left and arrow right
                    return false;
                }
            }
        }
    ]
    

    On the following demo you can see the results live. The only disadvantage which I see in the example is following: if you will try to type comma in the middle of the text, the cursor position (caret) will be changed to the end of the input after the replacement comma to point. Probably it is not a real problem in your case. It you do want to save the cursor position you should probably do this
    document.selection using for IE or .selectionStart and .selectionEnd for Firefox.

    UPDATED: I fixed the problem with the usage of e.keyCode inside of keypress event in the Firefox. I follows the information from here and use now e.charCode || e.keyCode instead of e.keyCode. The above code and the demo are fixed now.

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

Sidebar

Related Questions

I want to retrieve stack trace from a user dump file programmatically . There
I want to serialize some information I retrieve from the user in a small
i have a NSString instance ,i want to retrieve value from it and store
I want to retrieve records from a table which having fields like image_type and
I want to retrieve data from the database. The number of data is fixed
I want to retrieve data from sqlite. user can have more than 1 score
I want to retrieve data from stored procedure in table format like normal sql
I have a list of record Id's that I want to retrieve from Sql
I want to retrieve values from SQLite database in my Android application. Here in
I have DropDownList with CascadingDropDown extender. If I want to retrieve data from 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.