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

Discussion in 'Javascript' started by francisco lopez, Dec 30, 2004.

  1. 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:" 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="">
    <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="">
    <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 =
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ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 =
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ";
    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.toLowerCase();
    for (i=0; i<badwords.length; i++) {
    if (ffwords.indexOf(badwords)!= -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 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ";
    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="">
    <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>
    francisco lopez, Dec 30, 2004
    #1
    1. Advertising

  2. francisco lopez

    RobG Guest

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

    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
    RobG, Dec 31, 2004
    #2
    1. Advertising

  3. JRS: In article <>,
    dated Thu, 30 Dec 2004 09:42:51, seen in news:comp.lang.javascript,
    francisco lopez <> 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.
    Dr John Stockton, Dec 31, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexandre Martins

    Whats wrong with this provider ??

    Alexandre Martins, Aug 14, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    353
    Guenther Liebowitz
    Aug 14, 2003
  2. aa

    Whats wrong with numbers

    aa, Feb 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    305
    Patrice Scribe
    Feb 6, 2004
  3. Miguel Dias Moura
    Replies:
    7
    Views:
    479
    Miguel Dias Moura
    Sep 28, 2004
  4. Replies:
    1
    Views:
    361
    Victor Bazarov
    Aug 17, 2006
  5. shapper
    Replies:
    10
    Views:
    492
    Alexey Smirnov
    Nov 3, 2007
Loading...

Share This Page