Re: disable submit button

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Martin Honnen (Martin.Honnen_at_t-online.de)
Date: 03/10/04


Date: Wed, 10 Mar 2004 14:02:12 +0100


BoB Bedford wrote:

> On the same page, I can have 2 or 3 submit buttons (depends if the user is
> registered or not):
>
> not registered:
> Search Cancel
>
> registered
> Search Save Cancel
>
> Now, on a textbox, I've added a onKeyUp event
> (onKeyUp="javascript:testRecord();")
>
> My code for now:
> function testRecord(){
> if (document.FormSubmit.SearchAnnounce.value == ''){
> document.FormSubmit.SubmitButton[1].disabled = false;
> }
> else
> {
> document.FormSubmit.SubmitButton[1].disabled = true;
> }
> }
>
> This works fine when the user is registered (when they are 3 buttons) but
> not when they are only 2 buttons.
> I can't change the name of the buttons. So it's there any way to do it on a
> specific button if it' present only ?
> something like: document.FormSubmit.SubmitButton['Save'].disabled = true;

   document.forms.FormSubmit.elements.Save.disabled = ...
if you have
   <input type="submit" name="Save" ...>

-- 
	Martin Honnen
	http://JavaScript.FAQTs.com/

Quantcast