Java with forms issues


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Java with forms issues

  1. #1
    Join Date
    Jan 2006
    Posts
    5

    Unhappy Java with forms issues

    Maybe the 1st issue in not java related but I think the second one is.

    Here's what I am trying to do:

    1 -
    I want my forms to do the same thing that this forum does when you register or login...I want a "thank you" or "welcome" page where the data I put in the form are used to greet and verify the input. "Welcome Alley2006 we just sent you an e-mail at you@ you.com", etc.I could do that easily with front page but now I'm using dreamweaver and it is more complex to figure out.
    2 - I would also like to have a something like on this website www.namesdatabase.com. There is a form and not only it has alert boxes with error messages but at the end there is an alert box that asks you to confirm the data you input (it lists the data) and then click OK or Cancel. I looked for a javascript with this function everywhere.
    I copied and pasted the code and tried to modify it to fit my forms but it didn't work.
    Thank you so much!!

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    1: Server-side I would use servlet/jsp, php or perl (in that priority)... whatever the server could offer.
    2: You should look into the element/event model for javascript, but remember that there are significant differences in the way the different browsers have implemented this. As I have gathered only IE covers the lot.

    What is done here is that the submit button is supplied with an onclick handler that checks the form elements. If the check fails the onclick handler returns FALSE, which again stops the form from being submitted

    A GOOD book: O'Reilleys "JavaScipt - The Definitive Guide by David Flanagan"

    Btw. here is the code i fished out from the website, It looks like the verifier
    ... notice the 4-letter-word filter


    The x-parameter here is the form that is being validated.
    Code:
    function v(x) {
        var y = x.s_email; var z = x.s_name; var z1 = x.s_maiden_name;
        y.value = y.value.toUpperCase(); z.value = z.value.toUpperCase();
        z1.value = z1.value.toUpperCase(); y.value = q('WWW.','',y.value);
        y.value = p(y.value);
    if (z.value.indexOf(',') != -1) {
      var cm = z.value.indexOf(',');
      z.value = z.value.substr(cm + 1, z.value.length - 1) + ' ' +
          z.value.substr(0, cm);
    }
    for (var i = 0; i < 10; i++) {
      z.value = q(i.toString(), '', z.value);
    }
    for (var i = 0; i < 10; i++) {
      z1.value = q(i.toString(), '', z1.value);
    }
    z.value = q(':', '', z.value); z.value = q('>', '', z.value);
        z.value = q('<', '', z.value); z.value = q('^', '', z.value);
        z.value = q('[', '', z.value); z.value = q(']', '', z.value);
        z.value = q('{', '', z.value); z.value = q('}', '', z.value);
        z.value = q('|', '', z.value); z.value = q('_', '', z.value);
        z.value = q(';', '', z.value); z.value = q('@', '', z.value);
        z.value = q(' ','',z.value); z.value = q('.', '', z.value);
        z.value = q('~', '', z.value); z.value = q('*', '', z.value);
        z.value = q('!', '', z.value); z.value = q('/', '-', z.value);
        z.value = p(z.value); z.value = q(',', '', z.value);
        z1.value = q(':', '', z1.value); z1.value = q('>', '', z1.value);
        z1.value = q('<', '', z1.value); z1.value = q('^', '', z1.value);
        z1.value = q('[', '', z1.value); z1.value = q(']', '', z1.value);
        z1.value = q('{', '', z1.value); z1.value = q('}', '', z1.value);
        z1.value = q('|', '', z1.value); z1.value = q('_', '', z1.value);
        z1.value = q(';', '', z1.value); z1.value = q('@', '', z1.value);
        z1.value = q(' ','',z1.value); z1.value = q('.', '', z1.value);
        z1.value = q(',', '', z1.value); z1.value = q('~', '', z1.value);
        z1.value = q('*', '', z1.value); z1.value = q('!', '', z1.value);
        z1.value = q('/', '-', z1.value); z1.value = p(z1.value);
        var t = z.value;
        var tb = new Array('DR ','MR ','MRS'); var te = new Array(' MD ','PHD');
    for (i in tb) {
      if (t.indexOf(tb[i]) == 0)
        z.value = z.value.substr(tb[i].length, t.length - 1)
    }
    for (i in te) {
      if (t.indexOf(te[i]) == t.length - te[i].length)
        z.value = z.value.substr(0, t.length - te[i].length)
    }
    var f = t.substr(0, t.indexOf(' '));
        var l = t.substr(t.lastIndexOf(' ') + 1, t.length - 1);
        var e = 0; var ne = 0;
        var lf = new Array('ANON ','SMOE ','SHMO ','SCHMO ','BLOW ','BLOWER ','ME
                           ','FRIS ','POO ','MISTER ','FIRST ','LAST ','DOG ','SEX
                           ','SEXY ','MY ','DOC ','CHRIST ','BODY ','THERE ','COOL
                           ','LEFT ','YOU ','*** ','DUDE ','MAN ','BOY ','GIRL ','
                           DOE ','**** ','YOUR ','GOD ','**** ','**** ','BEAR ','NO
                           ','HA ','YO ','OK ','BYE ','HI ','DIE ','DUNNO ','DUNO
                           ','WHAT ','WHUT ','WHATEVER ','*** ','PISS ','***** ','
                           STUPID ','BALLS ','SUCK ','SUCKS ','SUCKER ','SUCKME ','
                           PENIS ','SHINY ','DUMB ','CRAP ','QUEEN ','PRIVATE ','
                           GOGO ','MEME ','THE ','WHY ','DOGG ','PLAYER ','DEATH
                           ','DOOM ','HOLE ','SUX ','CUTE ','UR ','STOP ','THINK
                           ','THIS ','FAT ','DO ','WHO ','DONT ','LOL ','TOTAL ','
                           FAG ','**** ','MUM ','ALL ','******* ','DUMPTY ','PUNK
                           ','ABC ','NAME ','SCHOOL ','DAWG ','PHONY');
    for (i in lf) {
      if (l == lf[i] || f == lf[i])
        ne = 1
    }
    if (l == f) {
      ne = 1
    }
    for (i in lf) {
      if (z1.value == lf[i])
        z1.value = ''
    }
    var lg = new Array('SOMETHING ','NOTHING ','SOMEONE ','SOMEBODY ','NOBODY ','
                       NOONE ','ANYONE ','ANYBODY ','LIKE ','BLAH ','DFG ','SDF ','
                       XYZ ','BUSINESS ','XXX ','SCHMOE ','SHMOE ','BLOWME ','YMOUS
                       ','POOP ','**** ','KRAZY ','CRAZY ','***** ','*** ','SCREW
                       ','ASSHOLE ','THIS IS ','THE ','IS ','AND ','I DONT ','--','
                       \'\'', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
                       '**** HEAD ','CUTIE ','FOREVER');
    for (i in lg) {
      if (t.indexOf(lg[i]) != -1)
        ne = 1
    }
    for (i in lg) {
      if (z1.value.indexOf(lg[i]) != -1)
        z1.value = ''
    }
    if (y.value == '' || y.value.indexOf('@') == -1 || y.value.indexOf('.') == -1 ||
        y.value.indexOf(' ') != -1) {
      alert('Please enter YOUR EMAIL ADDRESS in the TOP RIGHT box.\r\n\r\nYour
            access link will be sent there ONLY.');
            setTimeout('a.s_email.focus()',200);
      e = 1;
    }
    else if (ne ||
             t.indexOf('TEST') == 0 ||
                       t.indexOf('THE') == 0 ||
                                 t.indexOf('GO') == 0 ||
                                           t.indexOf('NO') == 0 ||
                                                     t.
                                                     indexOf('JOHN DOE') == 0 ||
        t.indexOf('JOE BLO') == 0 || z.value == '' || z.value.indexOf(' ') == -1) {
        alert('Please enter YOUR FULL NAME in the TOP LEFT box.');
              setTimeout('a.s_name.focus()',200); e = 1;
    }
        else if (x.s_birth_year.options[x.s_birth_year.selectedIndex].value == '') {
      alert('Please select YOUR BIRTH YEAR from the MIDDLE LEFT box.');
            setTimeout('a.s_birth_year.focus()',200);
      e = 1;
    }
    else if (parseInt(x.s_birth_year.options[x.s_birth_year.selectedIndex].value) >
             1992) {
      alert('You must be at least 13years old to use this service.');
            setTimeout('a.s_birth_year.focus()',200);
      e = 1;
    }
    else if (x.s_birth_year.selectedIndex > 90) {
      alert('Please select YOUR REAL BIRTH YEAR from the MIDDLE LEFT box.');
            setTimeout('a.s_birth_year.focus()',200);
      e = 1;
    }
    else if (x.s_country.options[x.s_country.selectedIndex].value == '') {
      alert('Please select YOUR HIGH SCHOOL COUNTRY from the MIDDLE RIGHT box.');
            setTimeout('a.s_country.focus()',200);
      e = 1;
    }
    if (!e &&
        confirm('Please verify YOUR INFORMATION,
                and then CLICK OK.\r\n\r\n * YOUR * Full Name:\t\t' +z.value +
                '\r\nEmail Address:\t\t' +y.value +
                '\r\nBirth Year:\t\t' +x.s_birth_year.options[x.s_birth_year.
                selectedIndex].text +
                '\r\nHigh School Country:\t' +x.s_country.options[x.s_country.
                selectedIndex].text +
                '\r\n\r\nBY CLICKING OK YOU AGREE TO OUR TERMS(linked below).')) {return true;
    }
        else
      return false;
    }
    Last edited by sjalle; 01-07-2006 at 10:33 AM.
    eschew obfuscation

Similar Threads

  1. Replies: 1
    Last Post: 11-06-2005, 11:32 PM
  2. Recommending a technology: Results
    By Michael Gautier in forum Architecture and Design
    Replies: 25
    Last Post: 06-21-2003, 11:12 PM
  3. Has Sun Given Up on the Desktop?
    By Lori Piquet in forum Talk to the Editors
    Replies: 114
    Last Post: 10-10-2002, 06:01 AM
  4. .NET vs. Enterprise Java: Who's Got Better Security?
    By Glen Kunene in forum Talk to the Editors
    Replies: 17
    Last Post: 03-23-2002, 12:43 AM
  5. Security Issues for Serious Java Developers
    By S. Rothenberg sr2594 in forum Talk to the Editors
    Replies: 0
    Last Post: 10-22-2001, 11:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center