PDA

View Full Version : submitForm88(); function does NOT executed , why ? If I put an alert like



leonidassavvides
02-10-2009, 08:51 AM
the below refers to
http://www.poliscarhire.com/administration/webmaster/contact-webmaster.php

submitForm88(); function does NOT executed , why ? If I put an alert like
onsubmit="alert('called function')"executed[success], well ?


<form action="contact-webmaster-processor.php" method="post" enctype="application/x-www-form-urlencoded" name="webmaster" target="_self" class="text_normal" id="webmaster" onsubmit="return submitForm88();" onreset="return confirm('Are you sure to reset form ?')">


in head as js file include

function submitForm88() // (document.webmaster)
{
alert("submitForm() called"); // var f = form;
if (document.getElementById['message'].value == "") {
alert("Error: Message cannot be blank!");
document.getElementById['message'].focus();
return false;
}
if (document.getElementById['email'].value == "") {
alert("Error: Username(email) cannot be blank!");
document.getElementById['email'].focus();
return false;
}
var retemplate0 = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; // /^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z\.]{2,4}/; // gosselin p.347
if (!retemplate0.test(document.getElementById['email'].value)) { //
alert("Error: Username must contain only letters, numbers, dash, dot, underscores(first part) and the 'at' sign!"); // @
document.getElementById['email'].focus();
return false;
}
}

Nile
02-10-2009, 12:53 PM
Use (' and '), not [' and '].

Here, try this:


function submitForm88() // (document.webmaster)
{
alert("submitForm() called"); // var f = form;
if (document.getElementById('message').value == "") {
alert("Error: Message cannot be blank!");
document.getElementById('message').focus();
return false;
}
if (document.getElementById('email').value == "") {
alert("Error: Username(email) cannot be blank!");
document.getElementById('email').focus();
return false;
}
var retemplate0 = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; // /^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z\.]{2,4}/; // gosselin p.347
if (!retemplate0.test(document.getElementById('email').value)) { //
alert("Error: Username must contain only letters, numbers, dash, dot, underscores(first part) and the 'at' sign!"); // @
document.getElementById('email').focus();
return false;
}
}




<form action="contact-webmaster-processor.php" method="post" enctype="application/x-www-form-urlencoded" name="webmaster" target="_self" class="text_normal" id="webmaster" onsubmit="submitForm88();" onreset="return confirm('Are you sure to reset form ?')">

codeexploiter
02-11-2009, 04:07 AM
document.getElementById is a function not an array or something like that.
https://developer.mozilla.org/En/DOM/Document.getElementById

leonidassavvides
02-11-2009, 09:11 PM
BUT EVEN alert("submitForm() called"); DO NOT EXECUTED, WELL?
I CORRECTED PROBLEM BUT ALERT STILL NOT EXECUTED EVEN THE OTHER CODE ?

smansakra
02-12-2009, 01:41 AM
hum use firefox and install firebug addon and see what error...