stauf
Jun 19th 2007, 12:57 pm
Hi, I'm one of todays new guys here for JS and PHP. I don't know either that well but I'm tryin to learn. I used to work with Delphi so I know flow and such.
My issue. I have a form that gets processed to a php page as an order form. What I need is a way to require one name field be filled in, and unless it is, the form will not continue to parse to the php page. Basically I need to trap the user until he/she provides their name. What I found/have now seems to know that the field is blank, but it doesn't trap the user, it simply continues to get parsed.
<script language="JavaScript" type="text/javascript">
<!-- Begin
function verify() {
var themessage = "You are required to complete the following fields: ";
if (document.order.nick.value=="") {
themessage = themessage + " - Handle";
}
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
document.order.submit();
}
else {
alert(themessage);
return false;
}
}
// End -->
</script>
// Then in the form
<form action="order.php" method="post" name="order" onSubmit="verify();">
// I've also tried the OnClick handler on the Sumbit buton, which yeilds the same results.
Any suggestions? Thanks!
My issue. I have a form that gets processed to a php page as an order form. What I need is a way to require one name field be filled in, and unless it is, the form will not continue to parse to the php page. Basically I need to trap the user until he/she provides their name. What I found/have now seems to know that the field is blank, but it doesn't trap the user, it simply continues to get parsed.
<script language="JavaScript" type="text/javascript">
<!-- Begin
function verify() {
var themessage = "You are required to complete the following fields: ";
if (document.order.nick.value=="") {
themessage = themessage + " - Handle";
}
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
document.order.submit();
}
else {
alert(themessage);
return false;
}
}
// End -->
</script>
// Then in the form
<form action="order.php" method="post" name="order" onSubmit="verify();">
// I've also tried the OnClick handler on the Sumbit buton, which yeilds the same results.
Any suggestions? Thanks!