Hello,
I bought modena template to be able to take advantage of the responsive design and be able to use an application on a mobile device. However, whenever I add the attribute of maxLength to an input text, it doesn't work on a mobile device. I have also tried to make the validation manually using Javascript, but the problem persists. I am using primefaces v 5.3. Hopefully you can help me with a workaround to fix this problem.
Thanks
Input text max length not working on Mobile Device
-
- Posts: 5281
- Joined: 29 Jun 2013, 12:38
This isn't a Primefaces or Layout issue. You could see this issue with the following HTML input tag;
<input type="text" maxlength="10" />
But, I added a workaround. I tested it with mobile device. it works fine for me. Please try;
<input type="text" maxlength="10" />
But, I added a workaround. I tested it with mobile device. it works fine for me. Please try;
Code: Select all
<script type="text/javascript">
//<![CDATA[
$(window).load(function() {
var $this = PF('test');
if($this) {
$this.jq.on('keypress.inputtext-maxlength', function(e) {
var value = $this.jq.val(),
length = value.length;
if(length > $this.cfg.maxlength) {
$this.jq.val(value.substr(0, $this.cfg.maxlength));
}
});
}
});
//]]>
</script>
// XHTML
<p:inputText widgetVar="test" placeholder="Name" maxlength="10"/>
Github Profile: https://github.com/mertsincan
-
- Information
-
Who is online
Users browsing this forum: No registered users and 16 guests