EasyUI
Home
Demo
Tutorial
Documentation
Download
Extension
Contact
Forum
EasyUI Forum
April 22, 2026, 10:54:44 AM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
:
Home
Help
Search
Login
Register
EasyUI Forum
>
General Category
>
EasyUI for jQuery
>
How to set maxlength of searchbox and accept only numeric?
Pages: [
1
]
« previous
next »
Print
Author
Topic: How to set maxlength of searchbox and accept only numeric? (Read 13984 times)
Aod47
Jr. Member
Posts: 85
How to set maxlength of searchbox and accept only numeric?
«
on:
June 28, 2020, 03:13:49 AM »
I tried code but not work.
Code:
$('#sb').searchbox('textbox').attr('maxlength', 10);
And how to set searchbox accept only numeric.
Thank you.
Logged
jarry
Administrator
Hero Member
Posts: 2307
Re: How to set maxlength of searchbox and accept only numeric?
«
Reply #1 on:
June 30, 2020, 07:20:05 PM »
Please try this code.
Code:
$('#sb').searchbox({
inputEvents: {
keypress:function(e){
var target = e.data.target;
var tmp = $('<span></span>');
tmp.html(String.fromCharCode(e.which));
var c = tmp.text();
tmp.remove();
if ('0123456789'.indexOf(c) >= 0){
return true;
} else {
return false;
}
}
}
})
$('#sb').searchbox('textbox').attr('maxlength',10);
Logged
Aod47
Jr. Member
Posts: 85
Re: How to set maxlength of searchbox and accept only numeric?
«
Reply #2 on:
July 05, 2020, 11:43:36 PM »
Work great!
Thank you
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> News
=> General Discussion
=> EasyUI for jQuery
=> EasyUI for Angular
=> EasyUI for Vue
=> EasyUI for React
=> Bug Report
Loading...