[thelist] Simple Javascript field checking

john at johnallsopp.co.uk john at johnallsopp.co.uk
Thu Feb 24 09:51:11 CST 2005


> John,
>
> On Thu, 24 Feb 2005 06:31:03 -0500 (EST), john at johnallsopp.co.uk
> <john at johnallsopp.co.uk> wrote:
>> Hi
>>
>> I'm using
>>
>> function checkEmail()
>> {
>>         if
>> (document.registrationForm.regEmail!=document.registrationForm.regEmail2)
>>         {
>>                 alert ("Emails not the same");
>>                 return false;
>>         }
>>         return true;
>> }
>>
>> wot I wrote myself to check onChange whether the second email is the
>> same as the first, in Firefox in Linux RH9.
>>
>> The problem is, if it alerts an error and I correct it, when I move
>> on, it alerts again. If I go back to the field and change nothing,
>> then it's OK.
>
> If you are triggering the validation onChange, then it's not
> necessarily "OK", its' just not getting validated again.
>
> Can you inclue how you are calling it with the onchange? What are you
> doing with the return true/false?

Hi Matt,

Quite so, I realised that after I'd written it. I changed it to onBlur:
<tr>
  <td>Email: </td>
  <td><input type="text" name="regEmail"></td>
</tr>
<tr>
  <td>Email (repeat): </td>
  <td><input type="text" name="regEmail2" onBlur="checkEmail();"></td>
</tr>

I still have the same issue.

I'm going to use the return true/false later when I do a final form
check. If any check returns false then I won't want to submit the
form. For now, I do nothing with it.

J


More information about the thelist mailing list