Forums

This topic is locked

[?] multiple onsubmit help [?]

Posted 19 Oct 2003 22:00:26
1
has voted
19 Oct 2003 22:00:26   posted:
hi, i was wondering whether someone could help me with this problem

I have a form and I would like to do a number of verification techniques on the data as well as disable the submit button

I have three different functions in 3 different <script></script> blocks.

heres the code for them:
<pre id=code><font face=courier size=2 id=code>
&lt;script language="JavaScript" type="text/javascript"&gt;
&lt;!--
function checkform ( form )
{
if (form.f_name.value == "" {
alert( "Please enter your First Name." );
form.f_name.focus();
return false ;
}
if (form.l_name.value == "" {
alert( "Please enter your Last Name." );
form.l_name.focus();
return false ;
}
if (form.email.value == "" {
alert( "Please enter your email address." );
form.email.focus();
return false ;
}
if (form.email2.value == "" {
alert( "Please verify your email address." );
form.email2.focus();
return false ;
}
if (form.username.value == "" {
alert( "Please enter your desired Username." );
form.username.focus();
return false ;
}
if (form.password.value == "" {
alert( "Please enter your Password." );
form.password.focus();
return false ;
}
if (form.password2.value == "" {
alert( "Please verify your password." );
form.password2.focus();
return false ;
}
if (form.email.value != form.email2.value)
{
alert('Those emails don\'t match! Please Try Again');
return false;
}
if (form.password.value != form.password2.value)
{
alert('Those passwords don\'t match! Please Try Again');
return false;
}
return true ;
}
//--&gt;
&lt;/script&gt;
&lt;SCRIPT LANGUAGE="JavaScript"&gt;

&lt;!-- Begin
function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailAddr.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter."
return (false)
}
// End --&gt;
&lt;/script&gt;
&lt;script language="JavaScript"&gt;
&lt;!--
function check(){
if (document.registration.agreetandc.checked){
document.registration.register.disabled = false;
}
}
//--&gt;
&lt;/script&gt;
&lt;script&gt;
function submitonce(theform){
if (document.all||document.getElementById) {
for (i=0;i&lt;theform.length;i++) {
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset"
tempobj.disabled=true
}
}
else
return false
}
&lt;/script&gt;
</font id=code></pre id=code>
and heres the form onsubmit code:
<pre id=code><font face=courier size=2 id=code>
onsubmit="return checkform(this); return submitonce(this);return checkEmail(this);"
</font id=code></pre id=code>

The onsubmit part, I have looked around the net and found that you can mix js script together by adding the ';' between each part, but its not working properly.
is there anything wrong with this code anyone?

if its not possible to all of those js parts,
does someone by any chance know how to make a javascript in one that:
verifies an email address (includes @ and .com and the data between it, and ensure there is data in the following textboxes:
f_name, l_name, email, email2, username, password, and password2
as well as disable the submit button so someone cannot press it again
AND also check that the data in email and email2 is the same as well as password and password2.
sorry about this guys, but its getting so annoying, ive been trying for AGES!

Replies

Replied 15 Jan 2006 02:06:39
15 Jan 2006 02:06:39 Branelsia Hart replied:
I was wondering if you ever got an answer for your question. I'm trying to do a similar thing: verify fields, and then redirect to thank you page on submit.
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
hi, i was wondering whether someone could help me with this problem

I have a form and I would like to do a number of verification techniques on the data as well as disable the submit button

I have three different functions in 3 different &lt;script&gt;&lt;/script&gt; blocks.

heres the code for them:
<pre id=code><font face=courier size=2 id=code>
&lt;script language="JavaScript" type="text/javascript"&gt;
&lt;!--
function checkform ( form )
{
if (form.f_name.value == "" {
alert( "Please enter your First Name." );
form.f_name.focus();
return false ;
}
if (form.l_name.value == "" {
alert( "Please enter your Last Name." );
form.l_name.focus();
return false ;
}
if (form.email.value == "" {
alert( "Please enter your email address." );
form.email.focus();
return false ;
}
if (form.email2.value == "" {
alert( "Please verify your email address." );
form.email2.focus();
return false ;
}
if (form.username.value == "" {
alert( "Please enter your desired Username." );
form.username.focus();
return false ;
}
if (form.password.value == "" {
alert( "Please enter your Password." );
form.password.focus();
return false ;
}
if (form.password2.value == "" {
alert( "Please verify your password." );
form.password2.focus();
return false ;
}
if (form.email.value != form.email2.value)
{
alert('Those emails don\'t match! Please Try Again');
return false;
}
if (form.password.value != form.password2.value)
{
alert('Those passwords don\'t match! Please Try Again');
return false;
}
return true ;
}
//--&gt;
&lt;/script&gt;
&lt;SCRIPT LANGUAGE="JavaScript"&gt;

&lt;!-- Begin
function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailAddr.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter."
return (false)
}
// End --&gt;
&lt;/script&gt;
&lt;script language="JavaScript"&gt;
&lt;!--
function check(){
if (document.registration.agreetandc.checked){
document.registration.register.disabled = false;
}
}
//--&gt;
&lt;/script&gt;
&lt;script&gt;
function submitonce(theform){
if (document.all||document.getElementById) {
for (i=0;i&lt;theform.length;i++) {
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset"
tempobj.disabled=true
}
}
else
return false
}
&lt;/script&gt;
</font id=code></pre id=code>
and heres the form onsubmit code:
<pre id=code><font face=courier size=2 id=code>
onsubmit="return checkform(this); return submitonce(this);return checkEmail(this);"
</font id=code></pre id=code>

The onsubmit part, I have looked around the net and found that you can mix js script together by adding the ';' between each part, but its not working properly.
is there anything wrong with this code anyone?

if its not possible to all of those js parts,
does someone by any chance know how to make a javascript in one that:
verifies an email address (includes @ and .com and the data between it, and ensure there is data in the following textboxes:
f_name, l_name, email, email2, username, password, and password2
as well as disable the submit button so someone cannot press it again
AND also check that the data in email and email2 is the same as well as password and password2.
sorry about this guys, but its getting so annoying, ive been trying for AGES!
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Reply to this topic