473,473 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Form validation - prevent certain buttons firing

I have a general form validation question. I know very little about
javascript, a little more about PHP. Using yav (http://yav.sourceforge.net):

<form method="POST" name=edit onsubmit="return performCheck('edit', rules,
'classic');" action="pages_edit_submit.php">
<input type="text" name="title">
<input type="submit" name="Save">
<input type="submit" name="Cancel">
</form>

.... PerformCheck fires when any submit button is click, which is logical but
I'd like to prevent this if it was the cancel button that was clicked (and
preserve form submission on pressing Enter whilst in the 'title' box.

Very many thanks

Nick

Jul 23 '05 #1
2 2244
Self answering question.

On 27/5/05 11:55 am, in article BE**************@privacy.net, "Nick Bell"
<me@privacy.net> wrote:
I'd like to prevent this if it was the cancel button that was clicked (and
preserve form submission on pressing Enter whilst in the 'title' box.


Declare another variable e.g. Var canc=false
In the onclick bit of the button you don't want to trigger the validation
routine insert "canc=true;"
In the onsubmit bit of <form> insert "return (performCheck() or canc);"

Apologies for holding you up, hope the solution helps someone in the future

Nick

Jul 23 '05 #2
Nick Bell wrote:
I have a general form validation question. I know very little about
javascript, a little more about PHP. Using yav (http://yav.sourceforge.net):

<form method="POST" name=edit onsubmit="return performCheck('edit', rules,
'classic');" action="pages_edit_submit.php">
<input type="text" name="title">
<input type="submit" name="Save">
<input type="submit" name="Cancel">
</form>

.... PerformCheck fires when any submit button is click, which is logical but
I'd like to prevent this if it was the cancel button that was clicked (and
preserve form submission on pressing Enter whilst in the 'title' box.


If you don't want the 'cancel' button to submit, don't make it a
submit button. Presumably you want to run the validation but not
submit the form, so why not just use a plain button with a
appropriate label?

<input type="button" value="Check form" onclick="
performCheck('edit', rules,'classic');
">

--
Rob
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Hosh | last post by:
I have a form on a webpage and want to use JavaScript validation for the form fields. I have searched the web for form validation scripts and have come up with scripts that only validate...
1
by: Tim | last post by:
We have a site under development that uses validation web controls to validate the data entered in text boxes. But when the user changes his mind and presses cancel, or navigates using a hyperlink to...
9
by: AFN | last post by:
I was just dropped into someone else's code (isn't that always so fun?). I can't figure out why a custom validation control's server event function is executing. There is nothing (that I see)...
4
by: Joe Abou Jaoude | last post by:
hi I m facing the following problem often : In a web page the user can click on 2 buttons "button1" and "button2". If the user clicked on button1 then I have to validate part of the form (some...
2
by: Adrian | last post by:
Hi everyone I have a web form where the validation works pefectly I copied the file, renamed it, and all of a sudden the validation stopped working(on the copied form). I have two panels on...
4
by: microb0x | last post by:
I have an application with a master form with a tab control containing nine tabs, each tab contains a subform. I have command buttons on my main form including: Save , Cancel , Close. My...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
5
by: raylopez99 | last post by:
I have a form, Form6, that has a bunch of buttons overlaid on it. I want to be able to click on any arbitrary area of the form, and if that area of the form is overlaid by a button, I want to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.