EasyUI Forum
September 19, 2025, 12:53:03 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: text focus event won't work  (Read 6986 times)
cannon
Newbie
*
Posts: 5


View Profile
« on: February 08, 2016, 12:23:17 AM »

The textbox focus event does not work, the value of x is correct, but the component is not filled with the new value, any tips? Regards.

Code:
    $(document).ready(function () {
        $('#txtSchool').textbox('textbox').bind('keypress focus blur', function (e) {
            CallEvents($(this), e);})
    });

    function CallEvents(Sender, e) {           
        if (e.type == 'focus') {
            var rd = $(Sender).prop('readonly');
            var rd = false; //testing...
            if (!rd) {
                var q = String($(Sender).val());
                var x = q.replace(/\./g, "a");   //replacing dot by a
                //$.messager.alert('School', 'focus ' + x, 'info');
                $(Sender).val(x);   //does not fill the required field with the x content
                return;
            }
        }
        else if (e.type == 'keypress') {
            //$.messager.alert('School', 'keypress ', 'info');
        }
        else if (e.type == 'blur') {
            //$.messager.alert('School', 'blur', 'info');
        }
    };
Logged
cannon
Newbie
*
Posts: 5


View Profile
« Reply #1 on: February 08, 2016, 04:45:39 AM »

ther's a bug... in my brain, or really the event on focus don't work

Code:
$('#txt').textbox('textbox').on('focus', function () {
       $(this).val("00000");         //don't set
});

or

$('#txt').textbox('textbox').bind('focus', function () {
       $(this).val("00000");         //don't set
});

or

$('#txt').textbox('textbox').bind('focusin', function () {
       $(this).val("00000");         //don't set
});

curiously the keypress event works!
« Last Edit: February 08, 2016, 05:35:22 AM by cannon » Logged
jarry
Administrator
Hero Member
*****
Posts: 2298


View Profile Email
« Reply #2 on: February 08, 2016, 05:47:21 AM »

Please refer to this example http://jsfiddle.net/vxh8ydfy/1/. It works fine.
Logged
cannon
Newbie
*
Posts: 5


View Profile
« Reply #3 on: February 08, 2016, 06:49:23 AM »

Thank you, Jarry.

In my aspx page is not working and the code is the same, I will study more.
« Last Edit: February 08, 2016, 06:57:54 AM by cannon » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!