By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,530 Members | 880 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,530 IT Pros & Developers. It's quick & easy.

forms using keyPress onChange to submit or not to submit

P: n/a
to submit or not to submit - that is the question
and I'm going to be designing some lengthy forms, where many of the
fields may be populated with data, and the user may only want to view
it.

In a perfect world, I'd have 2 buttons: Close and Submit - disabled
and Submit would become enabled - immediately - if data was changed.
otherwise the user could click "Close" and a php script could redirect
(header) to Default pg.

Any articles on this ? Has any one attempted this ? have advice ?

Dec 30 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a


<input ....
onkeypress="this.form.MYSUBMIT.disabled=false;this .onkeypress=null;">

<input type="submit" disabled name="MYSUBMIT">

afterwards enabling MYSUBMIT, it removes itself, to avoid any
further keypress checks once the typing started, no point checking
each time.
Danny
Dec 30 '05 #2

P: n/a
Thank you for your response.
My only concern is that this may be cumbersome to code with 30+ input
fields.
Is there a good way to apply this to the whole form ?

Dec 30 '05 #3

P: n/a
awebguynow wrote:
Thank you for your response.
Which response?

<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>
<URL:http://www.safalra.com/special/googlegroupsreply/>
My only concern is that this may be cumbersome to code with 30+ input
fields.
Is there a good way to apply this to the whole form ?


The `keypress' event is documented (in MSDN) and tested (in Mozilla/5.0
rv:1.8) to bubble:

<form ...
onkeypress="this.elements['MYSUBMIT'].disabled = false;
this.onkeypress = null;">
...
</form>

<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onkeypress.asp>
PointedEars
Dec 30 '05 #4

P: n/a
On 2005-12-30, awebguynow <i_****@hotmail.com> wrote:
to submit or not to submit - that is the question
and I'm going to be designing some lengthy forms, where many of the
fields may be populated with data, and the user may only want to view
it.

In a perfect world, I'd have 2 buttons: Close and Submit - disabled
and Submit would become enabled - immediately - if data was changed.
otherwise the user could click "Close" and a php script could redirect
(header) to Default pg.

Any articles on this ? Has any one attempted this ? have advice ?


it doesn't sound like it will give much trouble.

start with submit enabled and disable it using javascript (so that users
with script turned off can still submit)

give the editable fields an onchange event handler that enables the submit
button

but anyway: what harm is there in always submitting?

Bye.
Jasen
Dec 30 '05 #5

P: n/a
On 2005-12-30, awebguynow <i_****@hotmail.com> wrote:
Thank you for your response.
My only concern is that this may be cumbersome to code with 30+ input
fields.
Is there a good way to apply this to the whole form ?


you could apply onkeypress to the <form>,

onkeypress won't help if the user edits the form without using the keyboard.
- you need onchange on the fields too.

you could do a script that loops through the form fields and installs the
handler.

Bye.
Jasen
Dec 30 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.