metomeya
10-01-2008, 07:02 PM
I'm a student taking a CIS class, so I hope this isn't too basic of a question for ya.
Anyways I'm trying to have an alert popup box come up when you don't enter your name in an input and keep that person from going to the next page.
I can get an alert message to pop-up
I can get it to keep form going to my next website
I can get it to use if statement with vars i define in it like (var test = 0; if (test==0) {blah blah})
But I can't get it to use firstname in the if statement.
Heres part of my code for my Confirm.js:
// JScript File
function valid()
{
var fname = document.getElementById("firstname");
if (fname ==" ")
{
alert("You did not fill in your first name");
return false;
}
}
Heres part of my code for my Default.aspx:
<head>
<script src="Confirm.js" type="text/javascript"></script>
</head>
<body>
<form id="timeform" action="none.aspx" method="post">
First name: <input type="text" name="firstname"/>
<input type="submit" value="Clock In/Out" onclick="return valid()" />
</form>
</body>
Is there something i'm doing wrong here?
Thanks
Anyways I'm trying to have an alert popup box come up when you don't enter your name in an input and keep that person from going to the next page.
I can get an alert message to pop-up
I can get it to keep form going to my next website
I can get it to use if statement with vars i define in it like (var test = 0; if (test==0) {blah blah})
But I can't get it to use firstname in the if statement.
Heres part of my code for my Confirm.js:
// JScript File
function valid()
{
var fname = document.getElementById("firstname");
if (fname ==" ")
{
alert("You did not fill in your first name");
return false;
}
}
Heres part of my code for my Default.aspx:
<head>
<script src="Confirm.js" type="text/javascript"></script>
</head>
<body>
<form id="timeform" action="none.aspx" method="post">
First name: <input type="text" name="firstname"/>
<input type="submit" value="Clock In/Out" onclick="return valid()" />
</form>
</body>
Is there something i'm doing wrong here?
Thanks