solarisuser Posted August 13, 2007 Share Posted August 13, 2007 Hi All, I am having a tough time trying to figure out how to go about this... I would like to have the form submit when my <input type=text> field has five digits typed in. Any help would be most appreciated! Thanks Link to comment https://forums.phpfreaks.com/topic/64755-solved-automatic-form-submit-after-five-digits-entered-in/ Share on other sites More sharing options...
emehrkay Posted August 13, 2007 Share Posted August 13, 2007 I'm typing this o my phone, for give errors and cb stands for curly braces as I am unable to find them on this keyboard both your form and formfield needs unique ids. function fieldsubmit()cb var field = documentGetElemetById(fieldid); field.onkeyup = function()cb if(field.length greaterthan 5) documentGetElemetById(formid).submit(); cb cb lol it looks strage on my phone, I hope that it helps Link to comment https://forums.phpfreaks.com/topic/64755-solved-automatic-form-submit-after-five-digits-entered-in/#findComment-323008 Share on other sites More sharing options...
php_tom Posted August 13, 2007 Share Posted August 13, 2007 Small bug: emehrkay's code will submit after 6 digits are typed. So it should be: function fieldsubmit() { var field = documentGetElemetById(fieldid); field.onkeyup = function() { if(field.length >= 5) documentGetElemetById(formid).submit(); } } BTW, this code will automatically submit after 5 CHARS are inputted, you should probably still check that they are digits... but that's just a detail. Link to comment https://forums.phpfreaks.com/topic/64755-solved-automatic-form-submit-after-five-digits-entered-in/#findComment-323027 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.