I've a function that validate a form field:
<html>
<head>
<script language="JavaScript">
function CheckFields(FormSubmit,BtnName)
{
if (BtnName!="Cancel")
{
check = true;
if (FormSubmit.User_Account.value == ""){
alert ("Username compulsory");
FormSubmit.User_Account.focus();
return false;
}....
My FORM:
<form action="<?php echo $editFormAction; ?>" name="formSubmit"
method="POST"> <!--form action myself-->
....
<input type="submit" name="SubmitButton" value="Add"
onClick="CheckFields(this.form, this.value)">
<input type="submit" name="SubmitButton" value="Cancel">
Now, if I click on cancel, I do redirect (with PHP) to a previous page. If I
click on Add, a check is done on the compulsory fields. I would like the
focus on the selected field (the one that isn't right), but the form is
reloaded. How to avoid this ?
I've tried to put the check on the form.OnSubmit (that fires before I submit
the form, and set the buttons input type as "button" instead of "submit"),
instead of the button click (that does submit the form), but I can't
retrieve with button was pushed. (I've tried FormSubmit.SubmitButton.name,
but it doesn't work)
Please help. 3 2628
"Bob Bedford" <be******@YouKnowWhatToDohotmail.com> wrote in
news:3f**********************@news.sunrise.ch: <input type="submit" name="SubmitButton" value="Add" onClick="CheckFields(this.form, this.value)"> <input type="submit" name="SubmitButton" value="Cancel">
Now, if I click on cancel, I do redirect (with PHP) to a previous page. If I click on Add, a check is done on the compulsory fields. I would like the focus on the selected field (the one that isn't right), but the form is reloaded. How to avoid this ?
Your event handler needs to *return* the value from CheckFields:
onClick="return Checkfields..."
Thanks Eric...it was that simple !!!
Regards
"Eric Bohlman" <eb******@earthlink.net> a écrit dans le message de
news:Xn*******************************@130.133.1.4 ... "Bob Bedford" <be******@YouKnowWhatToDohotmail.com> wrote in news:3f**********************@news.sunrise.ch:
<input type="submit" name="SubmitButton" value="Add" onClick="CheckFields(this.form, this.value)"> <input type="submit" name="SubmitButton" value="Cancel">
Now, if I click on cancel, I do redirect (with PHP) to a previous page. If I click on Add, a check is done on the compulsory fields. I would like the focus on the selected field (the one that isn't right), but the form is reloaded. How to avoid this ?
Your event handler needs to *return* the value from CheckFields: onClick="return Checkfields..."
in case you have a lot of forms to implement
and a lot of rules to follow or fields to validate
you shoudl check out PEAR:HTML_QuickForm.
it also supports client-side validation via
auto-generated or customly written javascript
functions. http://pear.php.net/package/HTML_QuickForm This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Stefan Richter |
last post by:
Hi, after coding for days on stupid form validations -
Like:
strings (min / max length), numbers(min / max value), money(min / max
value), postcodes(min / max value), telefon numbers,
email...
|
by: Rob Meade |
last post by:
Hi all,
I have a login page which has username and password fields, a login button,
and 2 validation controls (one for each field) - currently I have controls
to display to the summary if the...
|
by: usl2222 |
last post by:
Hi folks,
I appreciate any assistance in the following problem:
I have a form with a bunch of dynamic controls on it. All the controls
are dynamically generated on a server, including all...
|
by: Fourge |
last post by:
Hi,
I have run into a very strange scenario. In developing an ASP.NET
application on framework version 1.1, I found that certain client-side
validation scripts were not being rendered. The...
|
by: Hong Hao |
last post by:
Recently, I was trying to modify an existing aspx page when client-side
validation on that page stopped working. I searched this group and the web
in general and found that other people have had...
|
by: julie.siebel |
last post by:
Hello all!
As embarrassing as it is to admit this, I've been designing db driven
websites using javascript and vbscript for about 6-7 years now, and I
am *horrible* at form validation.
To be...
|
by: Chris |
last post by:
Hi,
I have a form for uploading documents and inserting the data into a mysql
db. I would like to validate the form. I have tried a couple of Javascript
form validation functions, but it...
|
by: John Chan |
last post by:
Hi,
Im doing a maintenance application in ajax and coldfusion at work on IE6
exclusively. I have a save button on each form and i have to do various
validations server side and on client side...
|
by: Gobind |
last post by:
Hello
I have been working on this for quite some time now, and have no clue
why my app behaves the way it does.
Here is the code snippet that controls this behaviour....
|
by: Andrew Falanga |
last post by:
HI,
Just a warning, I'm a javascript neophyte. I'm writing a function to
validate the contents of a form on a web page I'm developing. Since
I'm a neophyte, this function is quite simple at...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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,...
|
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...
| |