Instant validation problem



Hi Guys, i hope one of you are able to help with my problem. I'm a
novice when it comes to Javascript, but i'm trying to write a script
that performs instant validation on a signup page (ajax style!)
Basically, when a user starts entering text in a field an image of a
tick or cross appears deppending on if the input is valid.

The code i have so far is being run on a keyup event trigger. I would
be really grateful if someone could advise me what i am doing wrong,
and how to fix the script. Firebug is not proving to be very
useful...

function validate_form(source)
{


if (source == "fname")
{
if (( document.form1.fname.value.length =>2 ) &&
( document.form1.fname.value.length =<30 ))
{
document.images[fnameimg].src= "imgs/style/good.png";
valid = true;

} else {
document.images[fnameimg].src= "imgs/style/error.png";
valid = false;
}
}
if (source == "sname")
{
if (( document.form1.sname.value.length =>2 ) &&
( document.form1.sname.value.length =<30 ))
{
document.images[snameimg].src= "imgs/style/good.png";
valid = true;

} else {
document.images[snameimg].src= "imgs/style/error.png";
valid = false;
}
}
if (source == "email")
{
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+
$/.test(form1.email.value))
{
document.images[emailimg].src= "imgs/style/good.png";
valid = true;

} else {
document.images[emailimg].src= "imgs/style/error.png";
valid = false;
}
}

if (source == "email_conf")
{
if ( document.form1.email.value ==
document.form1.email_conf.value )
{
document.images[email_confimg].src= "imgs/style/good.png";
valid = true;

} else {
document.images[email_confimg].src= "imgs/style/error.png";
valid = false;
}
}
if (source == "pswd")
{
if ( document.form1.pswd.value.length => 5 )
{
document.images[pswdimg].src= "imgs/style/good.png";
valid = true;

} else {
document.images[pswdimg].src= "imgs/style/error.png";
valid = false;
}
}
if (source == "conf_pswd")
{
if ( document.form1.pswd.value ==
document.form1.conf_pswd.value )
{
document.images[conf_pswdimg].src= "imgs/style/good.png";
valid = true;

} else {
document.images[conf_pswdimg].src= "imgs/style/error.png";
valid = false;
}
}
if (source == "submitdata")
{
return valid;
}

}



I am trying to load this as an external file if that makes any
difference.

Many thanks,
Gavin
.



Relevant Pages

  • Re: OT - where to invest
    ... criticism is that JQuery is the work of a near novice and ... Now if we are precise the same way on the term 'novice', well, I suspect ... Javascript outside the schoolclasses, by themselves, in a disordered ... apparently easiness of adding some script to a HTML page to obtain some ...
    (comp.lang.javascript)
  • Re: OT - where to invest
    ... criticism is that JQuery is the work of a near novice and ... Now if we are precise the same way on the term 'novice', well, I suspect ... Javascript outside the schoolclasses, by themselves, in a disordered ... apparently easiness of adding some script to a HTML page to obtain some ...
    (comp.lang.javascript)
  • VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
    ... Job is to convert that JAVASCRIPT code into SIMPLE VBA code ... Here's a bookmarklet that will tell you whether or not the browser ... JS sends request to the server (to a PHP script) ... This is the PHP script. ...
    (microsoft.public.vb.controls.internet)
  • VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
    ... Job is to convert that JAVASCRIPT code into SIMPLE VBA code ... Here's a bookmarklet that will tell you whether or not the browser ... JS sends request to the server (to a PHP script) ... This is the PHP script. ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted
    ... Job is to convert that JAVASCRIPT code into SIMPLE VBA code ... Here's a bookmarklet that will tell you whether or not the browser ... JS sends request to the server (to a PHP script) ... This is the PHP script. ...
    (microsoft.public.vb.6.webdevelopment)