Click to See Complete Forum and Search --> : onsubmit


g_vikram_uk
12-27-2003, 02:36 PM
neeedddd help
cant get two on submit functions to be called one afterthe other and both work¬???!?!?!?


:confused: :confused: :confused:

have a look please anyone

newmwmber (http://simt-dev.unl.ac.uk/vikram/newmember.html)

fredmv
12-27-2003, 02:47 PM
That page doesn't have any JavaScript on it.

g_vikram_uk
12-27-2003, 02:59 PM
i got ahabit of doing that sorri
i have uploaded it now

fredmv
12-27-2003, 03:06 PM
It still doesn't have any JavaScript.

g_vikram_uk
12-27-2003, 03:07 PM
arghhh gimme 2mins

g_vikram_uk
12-27-2003, 03:08 PM
http://simt-dev.unl.ac.uk/vikram/newmember.html

g_vikram_uk
12-27-2003, 03:11 PM
<script lanaguage="javascript">
function check(){
if (document.form1.firstname.value ==""){
alert ("Please enter your First Name.");
document.form1.firstname.focus();
return false
}
if (document.form1.surname.value ==""){
alert ("Please enter your Surname.");
document.form1.surname.focus();
return false
}
if (document.form1.username.value ==""){
alert ("Please enter your User Name. Register to obtain one.");
document.form1.username.focus();
return false
}
if (document.form1.postalcode.value ==""){
alert ("Please enter your Postal Code.");
document.form1.postalcode.focus();
return false
}
if (document.form1.contactnumber.value ==""){
alert ("Please enter a Contact Number.");
document.form1.contactnumber.focus();
return false
}
if (document.form1.emailaddress.value ==""){
alert ("Please enter your Email Address.");
document.form1.emailaddress.focus();
return false
}
return false
}

function validatePwd() {

var invalid = " "; // Invalid character is a space
var minLength = 6; // Minimum length
var pw1 = document.form1.password.value;
var pw2 = document.form1.cpassword.value;


// check for a value in both fields.
{
if (pw1 == '' || pw2 == '') {
alert('Please enter your password twice.');
return false;
}

// check for minimum length
if (document.form1.password.value.length < minLength) {
alert('Your password must be at least ' + minLength + ' characters long. Try again.');
return false;
}


// check for spaces
if (document.form1.password.value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed.");
return false;
}
else {
if (pw1 != pw2) {
alert ("You did not enter the same new password twice. Please re-enter your password.");
return false;
}

}
}
}
</script>


</p><form name="form1" method="post" action="database/indianOccasions.mdb" onSubmit="return check(this) && validatePwd(this);">

ray326
12-27-2003, 10:37 PM
Have you tried onSubmit="return (check(this) && validatePwd(this));"?

g_vikram_uk
12-28-2003, 08:21 AM
thanks for the reply ray
i have tried that and it only seems to run the first check and skips the second one.

fredmv
12-28-2003, 08:24 AM
<script type="text/javascript">
//<![CDATA[
function verify()
{
return (check(document.forms[0]) && validatePwd(document.forms[0]));
}
//]]>
</script><form method="post" action="database/indianOccasions.mdb" onsubmit="return verify();">

g_vikram_uk
12-28-2003, 08:28 AM
nah sorri fredmv

that didnt work either,.
arghhhhhhh


i bin at this lil bit for over 2 days now

fredmv
12-28-2003, 08:29 AM
Sure that didn't work correctly? I just did a local test and it appeared to work alright.

g_vikram_uk
12-28-2003, 08:30 AM
let me try that again for ya

g_vikram_uk
12-28-2003, 09:10 AM
http://simt-dev.unl.ac.uk/vikram/newmember.html

ray326
12-28-2003, 06:13 PM
Originally posted by g_vikram_uk
thanks for the reply ray
i have tried that and it only seems to run the first check and skips the second one.
Did check(this) fail? If so then the other one will not be called. Javascript is one of many languages that do short circuit evaluation of boolean expressions like that.

ray326
12-28-2003, 06:14 PM
Originally posted by g_vikram_uk
http://simt-dev.unl.ac.uk/vikram/newmember.html
I hope not. It let me submit the form without touching any of the fields.

g_vikram_uk
12-28-2003, 07:21 PM
ray
the first validation did not fail. it jus seems to miss the second one altoghher