[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ajug-members]: jsp form question




OK, I have it now.  I used :

//for the submit button
onSubmit=validateFields();

//then in validateFields I got the form and checked each field for a value and then submitted when all had a value, like so:
var thisForm = document.forms[0];
               
                if(thisForm.comp.value == '')
                {
                        alert('Company name is required.');
                        thisForm.comp.focus();
                        return;
                }
                else if(thisForm.desc.value == '')
                {
                        alert('Short description is required.');
                        thisForm.desc.focus();
                        return;
                }
                else if(thisForm.addr.value == '')
                {
                        alert('An address is required.');
                        thisForm.addr.focus();
                        return;
                }
                ///....etc.
                else
                {
                        thisForm.method.value = 'POST';
                        thisForm.action = 'FormProcessor?action=a';
                        thisForm.submit();
                }

Thanks for the help everyone.  My problem is that I did not know you could perform the commands in that last else in javascript.

-Jason



"Jason Kretzer/STAR BASE Consulting Inc." <JKretzer@starbaseinc.com>

04/02/2004 09:01 AM

Please respond to
ajug-members@ajug.org

To
ajug-members@ajug.org
cc
Subject
[ajug-members]: jsp form question






Good morning all,


I have a question about form submission.  I have a jsp that has a form of about 12 input fields.  All of the fields are required to have something in them.  Is there a way to have a javascript to do this and then still POST the form to a servlet?


Thanks,


-Jason