Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

on click help...

Status
Not open for further replies.

thompom

Technical User
Dec 4, 2006
395
GB
Hi,

On a form my validation is done through the onclick event of a button

Code:
onclick="this.form.a.value='A';return EW_checkMyForm(this.form);"

function EW_checkMyForm
Code:
function EW_checkMyForm(EW_this) {
if (EW_this.x_stockreg && !EW_hasValue(EW_this.x_stockreg, "TEXT" )) {
            if (!EW_onError(EW_this, EW_this.x_stockreg, "TEXT", ">Please Enter Car Reg..."))
                return false; 
        }

return true;
}

this works fine - but i have an issue of impatient clickers so, to keep it simple i want an alert to popup
and say 'click once' - this would give the page time to submit [may be annoying for user - but stops the record being written twice!]

the process of events would then be

1) Button clicked
2) function EW_checkMyForm run to make sure x_stockreg field filled - if not return false
3) if x_stockreg filled then submit form with a value for A
4) alert saying click once

i dont think i can do all this without writing a new function but have limited experience and would really appreciate your help.

if i am not making sense please let me know.

thanks MG
 
Right before "return true;", add the alert:

Code:
...

alert('Your message here');
return true;

of course, you should not rely on client-side JavaScript for validation or dup-checking. For example, what if the user has JS disabled? They could submit as many times as they liked.

This sort of thing should always be done server-side, with client-side as a fall-back.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Dan said:
...This sort of thing should always be done server-side, with client-side as a fall-back.
Please consider what he mentions carefully. There are many ways to prevent dupes (for instance).

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
many thanks Dan - since this is an intranet app and i know all clients have JS enabled i am guna be lazy!
thanks for the guidance - anyone have a link to an ASP solution? - will make my own but clocks ticking
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top