The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> JavaScript Submitting with onclick
-darkness_complex-
post Nov 11 2009, 05:59 PM
Post #1





Group: Members
Posts: 1
Joined: 11-November 09
Member No.: 10,315



I'm working on writing something that will preform a Javascript 'check' on all data submitted and then posting it all as $_POST data. Right now the submit button doesn't seem to be working, it will fire the java-script, but cannot seem to move past that point.



<script type="text/Javascript">
function myfunction(email, password)
{
if(email == ""){
alert("Must fill in email field.");
return false;
}
else if(password == "")
{
alert("Must fill in password field.");
return false;
}
else
return true;
}
</script>
.
.
.
echo '<html>
<form method="POST" id="login" name="login" action="login.php">
<p>Email: <input type="text" name="email" size="25"></p>
<p>Password: <input type="password" name="password" size="25"></p>
<p><input type="button" value="Submit" name="Button 1" onclick="if(myfunction(login.email.value, login.password.value)==true){login.email.submit();login.password.submit();}">
<input type="reset" value="reset" onclick="return confirm(\'Are you sure you want to reset the form?\')" name="Button 2"></p>
</form>
</html>';
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Nov 12 2009, 04:42 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



Try using the onsubmit event of the form element: http://www.javascriptkit.com/javatutors/form6.shtml
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 24th April 2024 - 12:08 AM