View Full Version : form.indexOf

01-05-2012, 06:41 PM
I am trying to put together a form validation script....its my first attempt at not following a tutorial varbaitim, and it's not going well. I hope someone can give me some advice where i'm going wrong.

I have created four information boxes and a submit button:

<form name="test" onSubmit="return run()"/>
Email:* <input type="text" name="address" /><br/>
name:* <input type="text" name="name" /><br/>
Feedback:* <textarea name="fb" cols="20" rows="5" /></textarea><br/>
home address: <input type="text"name="home" /><br/>
<input type="submit" name="button" value="send" />

I am trying to get the user to input an Email address into box 1 and some information into boxes two and three and have it checked when they hit the submit button so I created this function:

function run(){
var string = document.test.address.value
alert("fill this out properly!!!")
return false
return true

Firstly I realise that this would not be a good script for a real world environment, but im just trying to learn programming.

My problem is that the alert message will pop pop up if an @ is not inputted into the box, but then I don't get anymore messages when the other boxes are left empty....why?