View Full Version : submit buttons without JS?

08-23-2005, 12:23 PM

I have a submit button in my site for the feedback form. I noticed yesterday that if I switch off JS, that it doesn;t work any longer. surely there is an alternative which doenst need JS? I lkooked at the buttons here, in this site, and they seem to be coded just like mine.

Now I know you'll say to me that there's a big lump of JS there. I know but, I have that for people who have JS on (the majority), to check their entry. I shall remove it when I put together the perl snippet which can replace that.

However, whether the user has JS on or not, I still want them to be able to submit the form.

<input class="submitbuttons" type="button" onClick="javascript:checkFields();"


08-23-2005, 01:05 PM
Would it work if you made it a submit button?

<input class="submitbuttons" type="submit" onClick="javascript:checkFields();" value="Preview">

Tristan Gray
08-23-2005, 01:59 PM
You are using a javascript submit button because you are using javascript to check for required fields on form submit. This means several things. You either don't have the ability to use cgi on your host or you are unsure of how to set it up. You cannot then use required fields without javascript. If you disable the javascript in the submit buttom people can send blank forms to you.

08-23-2005, 02:02 PM
He said "I shall remove it when I put together the perl snippet which can replace that."

He just wants something for the time being so that if they don't have javascript enabled the form can still be submitted. I think.

08-23-2005, 02:06 PM
Bazz ....

You should validate form with Perl ...

But, as for the Javascript thing, I know why you want to use it ...
because the validation works good and keeps the visitor on the
client side until the form is complete.

How about using the <noscript> tag, where you have both lines ...
something like this (but I didn't test it out):

<input class="submitbuttons" type="submit" onClick="javascript:checkFields();" value="Preview">
<noscript><input type="submit" value="Submit"></noscript>

Where <noscript> is executed if Javascripting is not enabled.

Or, enclose a complete separate <form> within <noscript> ...

08-23-2005, 05:48 PM
spot on mark87 :) and thanks all.

I'll try the submit/button thing mark as I had missed that earlier.

Blimey Max, that sounds like a duplication :( . I dislike that concept so I'd better put together a perl thing in the next day or so - before I forget - as I start to add more to this 'project'


Tristan Gray
08-23-2005, 06:41 PM
Yeah, it'd probably be better to just devote all your time and energy into the new perl script instead of having a mediating step in the process. Didn't catch that that was what you were up to. I still prefer PHP for all of this sort of stuff myself though.

PHP for President!

08-23-2005, 07:03 PM
Yeh, I'm gonna do the perl checker/validator over the weekend If I have time. But changing the 'button' to 'submit' made it work even if JS is off, though because it is a risk that was previously exploited, I shall leave it as is until I get the perl done.

Come to think of it... Thats why I had it that way. If the sender wasn;t going to tell me who they were, my site wasn;t going to let them send the form.
And to think it seems like it was someone who knows me, who exploited it before..
Thwack and double thwack!! :p

Thanks Guys.