Automatic form submission when fields are complete

Associate
Joined
24 Feb 2011
Posts
41
As part of a project I'm working on for a client, I've been asked if it's possible to have an HTML form automatically submitted whenever an input has been entered into a text field.

I've already put the code in place to automatically move onto a new field whenever a code of a certain length (always going to be 8 characters long) has been submitted. This is done using Javascript & the "on key up - autotab" function.

Once the 2nd text box has been filled (again, always going to be 8 characters long) I need to find a way of submitting this form automatically.

Can anyone point me in the right direction please?

Thanks in advance
 
on the onkeyup event just do a basic if statement to check if the box is full and call something like $(this).parent('form').submit() of whatever with your chosen javascript framework.
 
Thanks for the suggestion "lookitsjonno" but would you be able to show me how I would implement that? I'm useless with javascript!

I'm trying to do it like this:
<input type="text" name="EquipmentID" size="10" onKeyup="autotab(this, document.'myForm').submit()" maxlength=9> but obviously it's not working.

My form is called "myForm".

Thanks!
 
as you have the 'autotab' function, could you not have a call to a 2nd function within it that checks all the input text boxes and if they're complete, submit the form?

are you using jqeury? if so it'll make your JS life easier. if your autotab func says "is the txt box complete" - yes, move to the next one (if there is one) and you can then call "isFormComplete()" which goes something along the lines of:

var allOk=true;
$("input[type=text]").each(function(idx,obj) {
if($(obj).val().length!=8) {
allOk=false;
}
});
if(allOk) $("#MyForm").submit();
 
Back
Top Bottom