javascript - Maxlength in Webview textfields for PhoneGap apps on Android -
i trying implement maxlength in phonegap android not able restrict characters cause never fetches proper character code. character code delete key below code same character code other key.
$(".limit-thirtyfive").bind("paste", function(e) { // access clipboard using api if (e.keycode != 8 || e.keycode != 46) { if ($(this).val().length >= 33) { $(this).val($(this).val().substr(0, 33)); } } }); $('.limit-ten').keyup(function(e) { if (e.keycode != 8 || e.keycode != 46) { if ($(this).val().length >= 10) { $(this).val($(this).val().substr(0, 10)); } } });
length restriction on general
you can use maxlength
attribute of input element referring to.
<input type="text" maxlength="5"/>
restricting special characters
for getting done, may want use onchange
event of input fields. example below restricts user enter character 'a'
.
$('your_input').onchange(function(){ $(this).val($(this).val().replace(/a/g, '')); });
Comments
Post a Comment