EasyUI Forum
April 28, 2024, 06:22:31 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: maxlength for textbox  (Read 20501 times)
jaimi
Full Member
***
Posts: 119


View Profile
« on: October 31, 2014, 06:42:01 AM »

Why is that not working:

$(function() {
 
  $("#HOM_NAME").textbox({
   required: true,
 
 }).prop('maxLength', 6);
 
 
})//function

So far, I didn't get any helping answer on my latest posts.
I still can not figure aut a solution to set the maximum length of a textfield.

Regards
Jaimi
Logged
yamilbracho
Jr. Member
**
Posts: 64


View Profile Email
« Reply #1 on: November 01, 2014, 11:11:13 AM »

Try

$(function() {
  $("#HOM_NAME").textbox({
   required: true,
 }).attr("maxlength", 6);
})//function

HTH,
Yamil
Logged
jaimi
Full Member
***
Posts: 119


View Profile
« Reply #2 on: November 03, 2014, 10:39:56 PM »

I tried this allready, doesn'r work.
Any other ideas?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #3 on: November 03, 2014, 10:52:44 PM »

Please set the 'length' validation type to the textbox.
Code:
$("#HOM_NAME").textbox({
  required: true,
  validType: 'length[0,6]'
});
Logged
jaimi
Full Member
***
Posts: 119


View Profile
« Reply #4 on: November 04, 2014, 05:52:50 AM »

one can still put in more than 6 characters within the field. It is not valid then, but it is not the same as the maxlength attribute.

I solved it by creating my own textfield not using the jquery-textbox.

May you put this on the list for the next release.

Regards.
Jaimi
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #5 on: November 04, 2014, 07:15:27 AM »

If you really want to set the 'maxlength' attribute, you must get the inputing box first.
Code:
$("#HOM_NAME").textbox('textbox').attr('maxlength',6);
Logged
Opan Mustopah
Full Member
***
Posts: 164


Indonesia


View Profile Email
« Reply #6 on: January 09, 2015, 03:12:03 AM »

try this,

Code:
$.extend($.fn.textbox.defaults.rules, {
maxLength: {
validator: function(value, param){
return value.length <= param[0];
},
message: 'Maximum characters allowed only {0}'
}
});

it validate if value on input cannot more than param, and offcourse users cannot save data
hope it helps
Logged

-- Bajak Otak --
*** Sorry for my bad english :3 ***
--JeasyUI version 1.4--
rkpunjal
Newbie
*
Posts: 15


View Profile
« Reply #7 on: February 05, 2015, 11:08:09 AM »

This solution actually gets the textbox to behave as per the 'maxlength' standards (not allowing to key-in more characters)

Code:
$('#first-name').textbox();
$('#first-name').textbox('textbox').attr('maxlength', $('#first-name').attr("maxlength"));

or you can take a generic approach like this:

Code:
	$(function(){
$("input[class*='easyui-textbox'][maxlength][id]").each(function (i, elt) { // iterate all jeasyui textboxes having maxlength attribute and id attribute
// alert("found : " + elt.id );
$('#' + elt.id).textbox();
$('#' + elt.id).textbox('textbox').attr('maxlength', $('#' + elt.id).attr("maxlength"));

});
});
Logged
azizkhani
Newbie
*
Posts: 37


View Profile Email
« Reply #8 on: March 24, 2015, 01:03:57 PM »

This solution actually gets the textbox to behave as per the 'maxlength' standards (not allowing to key-in more characters)

Code:
$('#first-name').textbox();
$('#first-name').textbox('textbox').attr('maxlength', $('#first-name').attr("maxlength"));

or you can take a generic approach like this:

Code:
	$(function(){
$("input[class*='easyui-textbox'][maxlength][id]").each(function (i, elt) { // iterate all jeasyui textboxes having maxlength attribute and id attribute
// alert("found : " + elt.id );
$('#' + elt.id).textbox();
$('#' + elt.id).textbox('textbox').attr('maxlength', $('#' + elt.id).attr("maxlength"));

});
});


why just have id Huh?
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!