Reputation: 6490
I can't see a clear mistake in this code. Instead of validating my fields, it just tries to send my form and I don't know why.
This is my jsFiddle: http://jsfiddle.net/PAALA/
Other question, how to validate if select box was picked?
Upvotes: 1
Views: 83
Reputation: 102783
The Javascript code is crashing out on the third line when you try to get the value for "Project". Looks like you forgot to give that one a name.
Upvotes: 2
Reputation: 324750
Firstly, because of how JSFiddle works, defining a function with function foo() {...}
is unreliable. Instead, use foo = function() {...}
syntax.
Next, you have an error in your script when you try to access document.forms["bug_form"]["Project"].value
- there is no text input with that name.
Finally, to prevent accidental submission, do this:
validateBugForm = function() {
try {
// ALL YOUR ORIGINAL CODE HERE
}
catch(e) {
alert("An error occurred: "+e);
return false;
}
}
This will ensure that false
is returned, even if your code errs.
Upvotes: 3