472,805 Members | 1,206 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

TURNING CRAZY, is there a way to write it in a different way? whats wrong

I hope not sent I twice.

ok here is my problem,

the javascript form validation works perfect during I put a
emaildirection in the <form action:""> comand, like this:
<form action="mailto:bu**********@gmx.net" method="post"
name="formulario"
id="formulario" onSubmit="return chkFormular()">

but when I change it like this:

<form action="/cgi-bin/formmail" method="post" name="formulario"
id="formulario" onSubmit="return chkFormular()">

AND I ADD these two lines!!:

<input type=hidden name=email value="bu**********@gmx.net">
<input type=hidden name=url
value="http://www.butacasalada.tk/main.htm">

it sends me the form data but without javascript starting a
validation, it is like the form ignores all the javascript I wrote!!!

IS there some way to tell the /cgi-bin/formmail to send all the form
data to my emaildirection without writing these lines:

<input type=hidden name=email value="bu**********@gmx.net">
<input type=hidden name=url
value="http://www.butacasalada.tk/main.htm">

???????????

please help, I am so close to finish my web work.
regards

Francisco

following the complete script:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="JavaScript" type="text/javascript">

function checkEmail(str){
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
return true;
} return false;
}

function chkFormular()
{
var checkOK =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèé êëìíîïðñòóôõöøùúûüýþ0123456789--._@";
var checkStr = document.formulario.email.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("A ver pavo estas utilizando signos no permitidos para un
email, revísalo!");
document.formulario.email.focus();
return (false);
}

var checkOKa =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèé êëìíîïðñòóôõöøùúûüýþ";
var checkStra = document.formulario.nombre.value;
var allValid = true;
for (q = 0; q < checkStra.length; q++)
{
ch = checkStra.charAt(q);
for (d = 0; d < checkOKa.length; d++)
if (ch == checkOKa.charAt(d))
break;
if (d == checkOKa.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("A ver chavalote revisa tu nombre!");
document.formulario.nombre.focus();
return (false);
}

if(document.formulario.nombre.value.length < 2){
alert("no me creo que este sea tu nombre, revisa tu nombre!");
document.formulario.nombre.focus();
return false;
}

if(document.formulario.nombre.value == "") {
alert("Introduce tu nombre!");
document.formulario.nombre.focus();
return false;
}
if(document.formulario.email.value == "") {
alert("Introduce tu email!");
document.formulario.email.focus();
return false;
}
if(document.formulario.email.value.indexOf('@') == -1) {
alert("a ver amigo te has dejado la @ en tu email!");
document.formulario.email.focus();
return false;
}
var arsch = "@."
if(document.formulario.email.value.indexOf(arsch) > -1) {
alert("tio, tu email no es correcto!");
document.formulario.email.focus();
return false;
}

if(document.formulario.email.value.indexOf('.') == -1) {
alert("a ver chaval te has dejado un punto en tu email!");
document.formulario.email.focus();
return false;
}
if(document.formulario.email.value.length < 6){
alert("macho tu email aún no esta bien!");
document.formulario.email.focus();
return false;
}
if(!checkEmail(document.formulario.email.value)) {
alert("que eres disléxico, o no sabes poner tu email
correctamente?!");
document.formulario.email.focus();
return false;
}
var bunker =/^([_a-zA-Z0-9-]+)(\.[a-zA-Z0-9-_]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3})$/;
if (!bunker.test(document.formulario.email.value))
{
alert("me tomas el pelo? revisa tu email!");
document.formulario.email.focus();
return false;
}

var badwords=new Array("puta","puto","p.uta","p.uto","mierda","cabr ","cerdo","nazi","mamon",
"mamón", "maric", "monyas" , "culo", "polla", "poya" ,"merda" ,
"imbecil", "chupar", "chupa", "chúpa", "imbeciles",
"jode","capullo","capuyo");
var ffwords=document.formulario.comentario.value.toLow erCase();
for (i=0; i<badwords.length; i++) {
if (ffwords.indexOf(badwords[i])!= -1) {
alert("amigo, revisa tu comentario porque has introducido un insulto,
intenta ser diplomático!");
document.formulario.comentario.focus();
return false;
}
}
if(document.formulario.alias.value == "") {
alert("Introduce tu nickname o alias!");
document.formulario.alias.focus();
return false;
}

var checkOKak = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèé êëìíîïðñòóôõöøùúûüýþ";
var checkStrat = document.formulario.apellido.value;
var allValidt = true;
for (q = 0; q < checkStrat.length; q++)
{
ch = checkStrat.charAt(q);
for (d = 0; d < checkOKak.length; d++)
if (ch == checkOKak.charAt(d))
break;
if (d == checkOKak.length)
{
allValidt = false;
break;
}
}
if (!allValidt)
{
alert("revisa tu apellido!");
document.formulario.apellido.focus();
return (false);
}

if(document.formulario.nombrepeli.value == "") {
alert("Introduce el nombre de la peli!");
document.formulario.nombrepeli.focus();
return false;
}

if(document.formulario.criticapeli.value == "") {
alert("Pon tu crítica de la peli, por favor!");
document.formulario.criticapeli.focus();
return false;
}
if(document.formulario.criticapeli.value.length < 40){
alert("referente a la crítica de la peli que has escrito, pon un
poco más, no seas tan breve, por ejemplo siempre esta bién en poner
una pequeñísima sinopsis!");
document.formulario.criticapeli.focus();
return false;
}

if(document.formulario.elements[7].checked==false &&
document.formulario.elements[8].checked==false &&
document.formulario.elements[9].checked==false &&
document.formulario.elements[10].checked==false) {alert("por favor
valora la página web butacasalada");
document.formulario.elements[7].focus();
return false;
}

if(document.formulario.elements[12].checked==false &&
document.formulario.elements[13].checked==false &&
document.formulario.elements[14].checked==false &&
document.formulario.elements[15].checked==false &&
document.formulario.elements[16].checked==false &&
document.formulario.elements[17].checked==false &&
document.formulario.elements[18].checked==false) {alert("por favor
selecciona una o más secciones, por ejemplo peli actual y también
mejor peli del mes o simplemente peli actual!");
document.formulario.elements[12].focus();
return false;
}

if(document.formulario.elements[21].checked==false &&
document.formulario.elements[22].checked==false &&
document.formulario.elements[23].checked==false &&
document.formulario.elements[24].checked==false &&
document.formulario.elements[25].checked==false &&
document.formulario.elements[26].checked==false &&
document.formulario.elements[27].checked==false) {alert("por favor,
valora la peli que has visto, gracias!");
document.formulario.elements[21].focus();
return false;
}
}
</script>

</head>

<body bgcolor="#999999">
<form action="/cgi-bin/formmail" method="post" name="formulario"
id="formulario" onSubmit="return chkFormular()">
<input type=hidden name=email value="bu**********@gmx.net">
<input type=hidden name=url
value="http://home.arcor.de/butacasalada/main.htm">
<p align="justify"><br>
</p>
<p>tu nombre*:
<input name="nombre" type="text" id="nombre" value="">
</p>
<p>pon aqui tu alias o nickname*:
<input name="alias" type="text" id="alias">
</p>
<p>tu apellido:
<input name="apellido" type="text" id="apellido">
</p>
<p> tu emai*:
<input name="email" type="text" id="email">
</p>
<p>selecciona tu pa&iacute;s:
<SELECT name=pais size=1 VALUE="">
<option value="SPAIN" selected>ESPA&Ntilde;A</option>
<option value="AFGHANISTAN">AFGHANISTAN</option>
<option value="ALBANIA">ALBANIA</option>
<option value="Alemania">ALEMANIA</option>
<option value="ANDORRA">ANDORRA</option>

</SELECT>
</p>
<p> tienes p&aacute;gina web? pon la direcci&oacute;n completa (ej.
http://www.google.com)
aqui.
<input name="url" type="text" id="url">
</p>
<p>nos recomiendas una p&aacute;gina web? pon la direcci&oacute;n
completa (ej.
http://www.google.com) aqui.
<input name="links" type="text" id="links">
</p>
<p>que valoraci&oacute;n das al portal butacasalada* ?</p>
<table width="292">
<tr>
<td width="110"><label>
<input type="radio" name="valoracionweb" value="mala">
mala</label></td>
<td width="121" bgcolor="#000000"><div align="center"><img
src="kaka.jpg" width="38" height="39"></div></td>
</tr>
<tr>
<td><label>
<input type="radio" name="valoracionweb" value="regular">
regular</label></td>
<td bgcolor="#000000"><div align="center"><img src="STAR.jpg"
width="26" height="26"></div></td>
</tr>
<tr>
<td><label>
<input type="radio" name="valoracionweb" value="buena">
buena</label></td>
<td bgcolor="#000000"><div align="center"><img src="STAR.jpg"
width="26" height="26"><img src="STAR.jpg" width="26"
height="26"></div></td>
</tr>
<tr>
<td><label>
<input type="radio" name="valoracionweb" value="muy buena">
muy buena</label></td>
<td bgcolor="#000000"><div align="center"><img src="STAR.jpg"
width="26" height="26"><img src="STAR.jpg" width="26" height="26"><img
src="STAR.jpg" width="26" height="26"></div></td>
</tr>
</table>
<p>&nbsp;</p>
<p>tienes alguna idea de como mejorar el portal?, alg&uacute;n
comentario?</p>
<p>
<textarea name="comentario" cols="50" rows="4"
id="comentario"></textarea>
</p>
<p>ok una vez rellenado las formalidades, es la hora de que digas tu
opinion,
selecciona primero la seccion adecuada*:</p>
<p>
<input name="imageField" type="image" src="aabutacaactual.jpg"
width="60" height="74" border="0">
peli actual
<input type="checkbox" name="checkbox" value="seccionpeliactual">
</p>
<p>
<input name="imageField4" type="image" src="aaTRUNYOMES.jpg"
width="60" height="74" border="0">
peor peli mes
<input type="checkbox" name="checkbox2"
value="seccionpeorpelimes">
<input name="imageField5" type="image" src="aaTRUNYOano.jpg"
width="60" height="74" border="0">
peor peli a&ntilde;o
<input type="checkbox" name="checkbox3"
value="seccionpeorpeliano">
<input name="imageField6" type="image" src="aahallofshame.jpg"
width="60" height="74" border="0">
peor peli de la historia
<input type="checkbox" name="checkbox4" value="seccionshame">
</p>
<p>
<input name="imageField7" type="image" src="aaMEJORMES.jpg"
width="60" height="74" border="0">
mejor peli mes
<input type="checkbox" name="checkbox5"
value="seccionmejorpelimes">
<input name="imageField8" type="image" src="aamejorano.jpg"
width="60" height="74" border="0">
mejor peli a&ntilde;o
<input type="checkbox" name="checkbox6"
value="seccionmejorpeliano">
<input name="imageField9" type="image" src="aaBUTACADEORO.jpg"
width="60" height="74" border="0">
mejor peli de la historia
<input type="checkbox" name="checkbox7" value="seccionoro">
</p>
<p><br>
nombre de la peli*:
<input name="nombrepeli" type="text" id="nombrepeli" size="80">
</p>
<p>en que mes has visto la peli:
<select name="mes" id="mes">
<option value="enero" selected>enero</option>
<option value="febrero">febrero</option>
<option value="marzo">marzo</option>
<option value="abril">abril</option>
<option value="mayo">mayo</option>
<option value="junio">junio</option>
<option value="julio">julio</option>
<option value="agosto">agosto</option>
<option value="septiembre">septiembre</option>
<option value="octubre">octubre</option>
<option value="noviembre">noviembre</option>
<option value="diciembre">diciembre</option>
</select>
</p>
<p>valoraci&oacute;n de la pel&iacute;cula*: </p>
<table width="282">
<tr>
<td width="136"><label>
<input type="radio" name="valoracionpeli" value="trunyo
total">
trunyo total</label></td>
<td width="201" bgcolor="#000000">
<input name="imageField2" type="image" src="kaka.jpg" width="38"
height="39" border="0">
<input name="imageField22" type="image" src="kaka.jpg"
width="38" height="39" border="0"></td>
</tr>
<tr>
<td><label>
<input type="radio" name="valoracionpeli" value="mala">
mala</label></td>
<td bgcolor="#000000">
<input name="imageField23" type="image" src="kaka.jpg" width="38"
height="39" border="0"></td>
</tr>
<tr>
<td><label>
<input type="radio" name="valoracionpeli" value="regular">
regular</label></td>
<td bgcolor="#000000">
<input name="imageField3" type="image" src="STAR.jpg" width="26"
height="26" border="0"></td>
</tr>
<tr>
<td><label>
<input type="radio" name="valoracionpeli" value="interesante">
interesante</label></td>
<td bgcolor="#000000">
<input name="imageField32" type="image" src="STAR.jpg" width="26"
height="26" border="0">
<input name="imageField33" type="image" src="STAR.jpg"
width="26" height="26" border="0"></td>
</tr>
<tr>
<td><label>
<input type="radio" name="valoracionpeli" value="buena">
buena</label></td>
<td bgcolor="#000000">
<input name="imageField34" type="image" src="STAR.jpg" width="26"
height="26" border="0">
<input name="imageField35" type="image" src="STAR.jpg"
width="26" height="26" border="0">
<input name="imageField36" type="image" src="STAR.jpg"
width="26" height="26" border="0"></td>
</tr>
<tr>
<td><label>
<input type="radio" name="valoracionpeli" value="muy buena">
muy buena</label></td>
<td bgcolor="#000000">
<input name="imageField37" type="image" src="STAR.jpg" width="26"
height="26" border="0">
<input name="imageField38" type="image" src="STAR.jpg"
width="26" height="26" border="0">
<input name="imageField39" type="image" src="STAR.jpg"
width="26" height="26" border="0">
<input name="imageField310" type="image" src="STAR.jpg"
width="26" height="26" border="0"></td>
</tr>
<tr>
<td><label>
<input type="radio" name="valoracionpeli" value="obra
maestra">
obra maestra</label></td>
<td bgcolor="#000000">
<input name="imageField311" type="image" src="STAR.jpg" width="26"
height="26" border="0">
<input name="imageField312" type="image" src="STAR.jpg"
width="26" height="26" border="0">
<input name="imageField313" type="image" src="STAR.jpg"
width="26" height="26" border="0">
<input name="imageField314" type="image" src="STAR.jpg"
width="26" height="26" border="0">
<input name="imageField315" type="image" src="STAR.jpg"
width="26" height="26" border="0"></td>
</tr>
</table>
<p>recuerda que una peque&ntilde;a sinopsis siempre forma parte de
una buena
cr&iacute;tica!<br>
tu cr&iacute;tica de la peli aqu&iacute;, por favor*:</p>
<p>
<textarea name="criticapeli" cols="80"
id="criticapeli"></textarea>
</p>
<p>&nbsp;</p>
<p>lo siguiente es optativo, seguidamente podr&aacute;s criticar
programas de
la radio, la tele o obras teatrales.</p>
<p>selecciona el medio:</p>
<table width="80">
<tr>
<td><label>
<input type="radio" name="medio" value="radio">
Radio</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="medio" value="tele">
Tele</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="medio" value="teatro">
Teatro</label></td>
</tr>
</table>
<p>nombre del programa o obra de teatro:
<input name="nombremedio" type="text" id="nombremedio" size="60">
</p>
<p>valoraci&oacute;n:</p>
<table width="200">
<tr>
<td><label>
<input type="radio" name="valoracionradiotele" value="puta
madre">
buena</label></td>
<td><input name="imageField10" type="image" src="gold.jpg"
width="100" height="84" border="0"></td>
</tr>
<tr>
<td><label>
<input type="radio" name="valoracionradiotele" value="mierda">
mala</label></td>
<td><input name="imageField11" type="image" src="dose.jpg"
width="100" height="100" border="0"></td>
</tr>
</table>
<p>tu cr&iacute;tica aqui:</p>
<p>
<textarea name="criticaradiotele" cols="80" rows="4"
id="criticaradiotele">tu crítica aquí ...</textarea>
</p>
<p>&nbsp; </p>
<p>
<input type="reset" name="Reset" value="borrar todo">
<input type="submit" name="Submit2" value="enviar" >
<br>
</p>
<p><strong>para <font color="#663366" size="5">salir del
formulario</font> click</strong> <a href="main.htm"
target="mainFrame"><strong><font
size="5">aqui!</font></strong></a><br>
</p>
<p>
<label></label>
<br>
</p>
</form>
</body>
</html>
Jul 23 '05 #1
3 2097
On 30 Dec 2004 09:42:51 -0800, francisco lopez wrote:
following the complete script:


A 562 line post to demonstrate how you cannot include two fields in
a form? I suggest you prepare an SSCCE[1] of the problem, it will be
more likely to get you help.

[1] <http://www.physci.org/codes/sscce.jsp>

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Jul 23 '05 #2
francisco lopez wrote:
I hope not sent I twice.

ok here is my problem,

[...]

Dang I must be bored... your problems (but maybe not all of them):

1. As pointed out previously, you have two fields called "email".
Change the name *and* the id of one of them to something else that
is unique in the page.

2. When you break lines inside string literals, such as:

alert("A ver pavo estas utilizando signos no permitidos para un email,
revÌsalo!");

you must do it thusly:

alert("A ver pavo estas utilizando signos no"
+ " permitidos para un email, revÌsalo!");

Similarly for all the other strings that are broken by wrapping or
returns. Don't forget to add spaces where needed (e.g. just before
" permitidos").

3. The line:

for (d = 0; d < checkOKak.length; d++) {

has its curly brace wrong way around ( "}" instead of "{" )

4. You have referred form elements this way:

document.formulario.alias.value

It is better to refer to the forms collection like this:

document.forms['formulario'].alias.value

or even:

document.forms['formulario'].elements['alias'].value

I could post some corrected code, but I'll leave that up to you. I
reckon it will take about an hour or two and for me it's beddy-byes.

Happy 2005!! :-)

--
Rob
Jul 23 '05 #3
JRS: In article <b0**************************@posting.google.com >,
dated Thu, 30 Dec 2004 09:42:51, seen in news:comp.lang.javascript,
francisco lopez <bu**********@gmx.net> posted :

function checkEmail(str){
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
return true;
} return false;
}

That RegExp looks like the one that news:de.comp.lang.javascript gave
you; it obviously cannot accept recent forms of E-mail addresses,
because of (\.\w{2,3})+$ .

There's no need to do
if ( xxx ){
return true;
} return false;
as
return xxx ;
is much nicer.

You appear to have two distinct RegExps for testing E-addresses.

Your checkOK functions should be better with RegExps.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Oliver Andrich | last post by:
Hi everybody, I have to write a little skript, that reads some nasty xml formated files. "Nasty xml formated" means, we have a xml like syntax, no dtd, use html entities without declaration and...
11
by: doltharz | last post by:
Please Help me i'm doing something i though was to be REALLY EASY but it drives me crazy The complete code is at the end of the email (i mean newsgroup article), i always use Option...
4
by: techy techno | last post by:
Hii I am trying to write down a cdont aplication which will email the survey form to the TO address with the answers checked by the user using the survey form I am 100% sure that there is...
5
by: hijwel | last post by:
<script language="JavaScript"> <!-- document.write('<form name="combo"><select name="example" size="1 onChange="Draw()">'); document.write('<option value=none>Maak je keuze');...
12
by: Gnolen | last post by:
Hi, I am really getting crazy here! I just do not get why this happens with the borders of the td/tr! I just want a border on the bottom of the rows(or td) but I just can't do it!!! I have tried...
3
by: larrybud2002 | last post by:
I suspect many developers here have had to write a technical manual for their software, and I'm wondering if you have any info as to industry standards for formatting. For example, should a...
13
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a...
19
by: Daniel Billingsley | last post by:
I think it's really nice to be able to do code like someVariable = someMethod(new SomeClass("some text")); However, as method signatures are number and types of parameters, you're limited to...
2
by: kheitmann | last post by:
OK, so I have a blog. I downloaded the "theme" from somewhere and have edited a few areas to suit my needs. There are different font themes within the page theme. Long story short, my "Text Posts"...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.