newbie onreset and onsubmit

B

bbxrider

neither is working but am concentrating now just for onreset
here is the code for both:

<FORM onSubmit="
this.firstname.optional=true;
this.lastname.optional=true;
this.addr1.optional=true;
this.city.optional=true;
this.state.optional=true;
this.zip.min=0;
this.zip.max=99999;
this.homephone.optional=true;
this.email.optional=true;
return verify(this);
"
onreset =
return confirm("do you really want to erase everything entered and start
over from scratch?");

then the code for the reset button
<input type="SUBMIT" value="Submit Volunteer Information"> <input
type="RESET" value="Start Over">

basically the web page just flashes when i click the reset and submit
buttons
once i get the basic reset going then i will finish up on the verifications
am i missing some really basic coding here??
 
L

Lee

"bbxrider" said:
neither is working but am concentrating now just for onreset
here is the code for both:

<FORM onSubmit="
this.firstname.optional=true;
this.lastname.optional=true;
this.addr1.optional=true;
this.city.optional=true;
this.state.optional=true;
this.zip.min=0;
this.zip.max=99999;
this.homephone.optional=true;
this.email.optional=true;
return verify(this);
"
onreset =
return confirm("do you really want to erase everything entered and start
over from scratch?");


then the code for the reset button
<input type="SUBMIT" value="Submit Volunteer Information"> <input
type="RESET" value="Start Over">

basically the web page just flashes when i click the reset and submit
buttons
once i get the basic reset going then i will finish up on the verifications
am i missing some really basic coding here??

onreset = "return confirm('do you really want to erase everything entered and
start over from scratch?');"

The value of the onreset attribute has to be in quotes.
The argument to confirm should be all on one line.
 
B

bbxrider

thanks evertjan, for the clarfiication,
but why did you enclose your example within the <div
and change it to onclick.....
 
B

bbxrider

ok thanks again
any ideas on making onsubmit work?

1. does onsubmit within the form tags work at all? this doesn't work and
i've seen postings that it will never work
<FORM method="Post" action="phsVolunteerData.asp"
onsubmit="
alert('just testing to get onsubmit code to get invoked');
">

2. i am now trying this but does not work either
<input type="button" value="submit" onClick="verify(this.form)">
<script
verify(f)
}
alert('just testing to get onsubmit code to get invoked');
...........lots of verification code
return;
}

does it matter where the javascript code is placed within the html code??

Evertjan. said:
bbxrider wrote on 27 jul 2003 in comp.lang.javascript:
thanks evertjan, for the clarfiication,
but why did you enclose your example within the <div
and change it to onclick.....

To make it easily testable in test.html.

This [my answer] was about the multilineability syntax of a string,
not about form reset buttons.
 
E

Evertjan.

bbxrider wrote on 27 jul 2003 in comp.lang.javascript:
any ideas on making onsubmit work?

1. does onsubmit within the form tags work at all? this doesn't work
and i've seen postings that it will never work
<FORM method="Post" action="phsVolunteerData.asp"
onsubmit="
alert('just testing to get onsubmit code to get invoked');
">

2. i am now trying this but does not work either
<input type="button" value="submit" onClick="verify(this.form)">
<script
verify(f)
}

wrong one, should be {
alert('just testing to get onsubmit code to get invoked');
..........lots of verification code
return;
}

does it matter where the javascript code is placed within the html
code??

This should work:

<FORM method="Post" action="phsVolunteerData.asp"
onsubmit="alert('testing onsubmit');return true;">

and this:

<FORM method="Post" action="phsVolunteerData.asp"
onsubmit="alert('testing onsubmit');this.submit();return false;">

and this:

<form ....
<input type="button" value="submit"
onClick="return verify(this.form);">

verify(f) {
alert('just testing');
if (verifiedOK)f.submit();
return false;
}

and this:

<form ....
<input type="button" value="submit"
onClick="return verify(this.form);">

verify(f) {
alert('just testing');
return (verifiedOK);
}



not tested
 
B

bbxrider

wow super reply, many thanks and btw this a volunteer project for a
non-profit
animal shelter, so thanks not only from me but lots of dogs, cats, birds,
turtles.................
so one example worked, none of the examples that call the verify() function
work
which is critical

this worked to at least display the alert
<FORM method="Post" action="phsVolunteerData.asp"
onsubmit="alert('testing onsubmit');return true;">
onreset= "
return confirm('do you really want to erase ' +
'everything entered and start over from scratch?');"
this did not work
<FORM
onsubmit="
alert('this alert from the onsubmit in the '+
'form tag');
return verify(this);"
onreset= "
return confirm('do you really want to erase ' +
'everything entered and start over from scratch?');"
this is same function verify() for the above examples
function verify(f) {
// verifies all the fields set for verification and messages
var msg = "form length = " + f.length + " fields";
alert('alert msg now coming from the called verify() function');
<!-- next step below if alert ever works -->
<!-- return confirm('return true=ok or false=cancel'); -->
return false;
)

none of the <input type="button" options worked with the different verify
code, not even the alert came up
verify(f) {
alert('just testing');
return false; <!-- or return true as well -->
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,268
Latest member
AshliMacin

Latest Threads

Top