homepage Welcome to WebmasterWorld Guest from 54.166.113.249
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Disable form unless scripting on
My form uses javascript to do checks
Kenton

10+ Year Member



 
Msg#: 3326 posted 11:13 pm on Mar 9, 2005 (gmt 0)

Hi

I have a form that uses javascript to do various checks for valid email addresses, valid URLs, valid selections etc. It doesn't do the checks (obviously) if scripting is turned off.

So here is my [no brainer] question ...
If I disable the submit button thus:
<form name="BookingForm" action="/cgi-bin/formmail.cgi" method="POST" onSubmit="return CheckInput(this)">

...

<input type="submit" disabled name="Submit" value="Submit">

Can I then do something like this:
<script language='JavaScript'>
<!-- Submit.disabled = true; -->
</script>
<noscript>You must have scripting on to use this form.</noscript>

to enable the submit button if scripting is on?

Thanks

 

Bernard Marx

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3326 posted 11:25 pm on Mar 9, 2005 (gmt 0)

Remove the form's onsubmit handler,
and replace the the submit button with a normal button:

<input type="button" value="submit" onclick="if(checkInput(this.form))this.form.submit()">

You could alternatively set the submit button's disabled attribute, then set it to false when the page loads - I haven't tested that one.

Kenton

10+ Year Member



 
Msg#: 3326 posted 9:47 pm on Mar 13, 2005 (gmt 0)

Thanks Heaps

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved