Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Java with forms issues

Maybe the 1st issue in not java related but I think the second one is.
:SICK:
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!!
[977 byte] By [alley2006] at [2007-11-11 7:39:53]
# 1 Re: Java with forms issues
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 :cool:

The x-parameter here is the form that is being validated.

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 ','**** ','CUNT ','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;
}
sjalle at 2007-11-11 22:37:48 >