If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Trouble with onsubmit event in form

I'm trying to test some input boxes on submit, but its not working for some reason I tried playing with the action and method in the form with no luck. Maybe its my script but i couldn't find where. It should run the script on click of the submit. Thanks

When posting here please help us to help you by following the posting guidelines and wrapping your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.

Form validation of the pattern if (document.formname.formfield.value == "") - that is blank - is barely worthy of the name, and virtually useless, as even a single space, an X or a ? will return false, that is pass the validation. A proper name may only contain letters, hyphen, space and apostrophe.
Numeric values, such as zip codes and phone numbers, should be validated as such. Ditto email addresses. This topic has been covered many times before in this forum.

function submit(){

You should avoid giving names or id's to your variables/functions/arguments/forms words which are HTML/JavaScript methods/properties/attributes such as 'name' or 'id' or 'value' or 'test' or 'text' or 'checked' or 'click' or 'href' or 'closed' or 'go' or 'submit' or 'replace' or 'button' or 'radio' or 'parseInt'.

Users who have thanked Philip M for this post:

I checked all my brackets and it validates, also I posted that before you edited your post.
Also I typed all that code you did not all I need is help with a problem, what is this forum for if you can't get help.

Thanks I changed the name of the function and used separate if statements and it worked. The assignment was to display an error message if nothing is entered in the input boxes that's why I left them blank, otherwise I wouldn't leave them blank. Thanks for your help.

No idea how that got there, bullant. It is not in the code I tested. I must have pressed the a key instead of something else when I added my remark about form validation. But thank you for pointing it out - it might have caused a problem for CodyJava.

Last edited by Philip M; 11-15-2012 at 08:48 PM.

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.