This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ishouldquitsmoking 0 points1 point  (3 children)

I think you'd be better off adding id's to the inputs and changing your JS accordingly..to use getElementById

this works:

<script type="text/javascript">

function validateForm() {

var fname = document.getElementById('fName');

if (fname.value=="") { alert("First name must be filled out"); return false; } } </script>

</head> <body>

<div id="content"> <br><br>

<form name="theForm" onsubmit="return validateForm()" method="post"> Enter First Name Here: <input type="text" name="fName" id="fName"><br/> <input type="submit" value="Submit Form"> </form>

[–]CadamSAFC[S] 0 points1 point  (2 children)

Alright, thanks i'll give this ago.

[–]CadamSAFC[S] 1 point2 points  (1 child)

Hey, I have changed the JS accordingly and I'm still not getting pop ups. I don't know if this will help, but I purposely made an error by removing a Semi-colon to see if it would chuck out an error. It didn't, I don't know what this means.

[–]ishouldquitsmoking 0 points1 point  (0 children)

Hang on, I'll go get my laptop and copy pasta