EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jahangir on April 16, 2024, 04:25:45 AM



Title: Restrict user input to only numbers in easyui $.messager.prompt
Post by: jahangir on April 16, 2024, 04:25:45 AM
How do I restrict user input to only numbers in easyui $.messager.prompt


Title: Re: Restrict user input to only numbers in easyui $.messager.prompt
Post by: jarry on April 18, 2024, 01:27:26 AM
Please try this code.
Code:
var msg = $.messager.prompt('My Title', 'Please type something', function(r){
if (r){
alert('you type: '+r);
}
});
msg.find('.messager-input').attr('type','number')


Title: Re: Restrict user input to only numbers in easyui $.messager.prompt
Post by: jahangir on April 21, 2024, 10:08:28 PM
Thanks Jarry, it works.
I changed your code from:
msg.find('.messager-input').attr('type','number');
to:
msg.find('.messager-input').numberbox({width:'100%'});
to convert the input to an EasyUI numberbox.