simple validate form

M

Mattia

Hi!
I would like to validate a fiels in a form, but the code I wrote doesn't
seem to work:

HTML:

<form name="formNome" method="post" action="/index.php" onSubmit="return
check_profilo_cambia( this )">
<input type="text" name="nome" value="Mattia"><br>
</form>

script:
function check_profilo_cambia( myForm )
{
if( myForm.nome.value.length < 2 )
{
alert( "il nome deve essere composto da un minimo di 2 caratteri");
return false;
}
[...]

the js debugger keep saying that myForm.nome has no properties.

Thanks
 
P

Philip Ronan

Hi!
I would like to validate a fiels in a form, but the code I wrote doesn't
seem to work:

HTML:

<form name="formNome" method="post" action="/index.php" onSubmit="return
check_profilo_cambia( this )">
<input type="text" name="nome" value="Mattia"><br>
</form>
.... etc...

Maybe the problem is with name="nome"

This is likely to clash with another attribute of the "form" object.

Try changing it to name="fullname" or something.

Phil
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,077
Messages
2,570,566
Members
47,202
Latest member
misc.

Latest Threads

Top