Click to See Complete Forum and Search --> : Form validation


Cesark
11-07-2003, 06:02 AM
What does this code do? Step by step, please ;)

<a href="javascript:document.myForm.submit();" onclick="validar(); return(false);"><strong>ENVIAR DATOS - SIGUIENTE</strong></a>

My doubt is: Why when you click the button begins 'validate()' function and other functions that not appears in this code?

I attached the 'validar()' function

Charles
11-07-2003, 06:07 AM
I don't know where you got that piece of script, but it is problematic on quite a number of points. If you are studying it in an attempt to learn JavaScript then stop before you do yourself, and the visitors to your sites, any more harm.

Cesark
11-07-2003, 06:32 AM
It is not possible that this code be problematic!. This one comes from one of the best sites in Europe, have 1.500.000 users and every day thousands of new users fills this form. I am a user of this site and it is the best fast site that I have never seen, according to the number of data that works at the same time.
Maybe is too difficult to begin with this level, but permit me to doubt about the problems of this code.

Charles
11-07-2003, 06:41 AM
1) That is a JavaScript dependant link, it will not work for the 13% of users who do not use JavaScript. And because some with certain disabilities cannot use JavaScript, it is illegal on some web sites in some parts of the world.

2) It uses the pseudo URL scheme "javascript:". You will find that on some, more moddern browsers that it does not give you the results that you expect.

3) "false()" is not, or at least should not be, a function or method. It does not take a parameter.

4) It is wrong to use the STRONG element simply to cause bold print. Unles you are indicating strong emphasis, you should use style sheets.

Cesark
11-07-2003, 07:14 AM
I can not discuss your comments because I am a beginner.

I am trying to find a way to begin forms validation, and I found to write the whole functions in the same page is very confuse when you read it later, and I will need 4 or 5 functions to validate my form. For that reason I want to know if the '<Script src="whatever.js">' is a good solution or not.