473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem Validating One Input Before Going On To Another.

I have a form with multiple input boxes. I want to validate each input
box (and force user to correct it) before allowing user to move to
another, either using tab key or a mouse click.

I try onchange/on blur to activate a javascript function to check the
input for correctness once user moves out of the input box (tab or mouse
click). If it looks OK, then nothing happens. But if an error is
detected, the function puts out an alert box and then use focus() and
select() methods to bring the focus back to the error'ed input box.

The result of the coding is that the error'ed input was selcted, but the
cursor still goes to the NEXT input box. It looks like the focus()
method did not last.

I suspect that the mouse click event still takes place after focusing on
the error'ed input box.

My question then is: Is there a way to stop that, and keep the focus on
the error'ed box? I really do not like to validate all the input boxes
AFTER the user enters all the inputs.

Thanks for the help.
Jun 23 '07 #1
3 2144
On Jun 23, 2:32 pm, Louis <t051...@hotmail.comwrote:
I have a form with multiple input boxes. I want to validate each input
box (and force user to correct it) before allowing user to move to
another, either using tab key or a mouse click.

I try onchange/on blur to activate a javascript function to check the
input for correctness once user moves out of the input box (tab or mouse
click). If it looks OK, then nothing happens. But if an error is
detected, the function puts out an alert box and then use focus() and
select() methods to bring the focus back to the error'ed input box.

The result of the coding is that the error'ed input was selcted, but the
cursor still goes to the NEXT input box. It looks like the focus()
method did not last.

I suspect that the mouse click event still takes place after focusing on
the error'ed input box.

My question then is: Is there a way to stop that, and keep the focus on
the error'ed box? I really do not like to validate all the input boxes
AFTER the user enters all the inputs.
Hard to say without having the code or a URL to look at.
In any case, I'd say bite the bullet and validate after,
nothing annoys people more than being told what to do,
especially with f'n dialog boxes that pop up and insist
on being paid attention to.

*PING* "Hi, look at me, you screwed up, moron, fix it
now or else. But before I'll allow you the privilege
of fixing your asinine infantile error, you've got to
click my button or I won't go away."

On a personal note, I've gone to sites to place orders,
for a fair bit of dosh, only to walk away and spend the
money somewhere else because the person programming the
interface couldn't be bothered to make it more friendly.

---
Geoff

Jun 23 '07 #2
ASM
Louis a écrit :
I have a form with multiple input boxes. I want to validate each input
box (and force user to correct it) before allowing user to move to
another, either using tab key or a mouse click.
it is not a good way to do

prefer to validate these fields on submit

function validate(what) {
var F = what.elements;
for(var i=0; i<F.length; i++) {
if(F[i].type=='text' && F[i].value.length<=0) {
alert('please complete field : '+F[i].name);
F[i].focus();
F[i].select()
return false;
}
}
return true;
}
<form onsubmit="return validate(this);" blah >

--
Stephane Moriaux et son (moins) vieux Mac
Stephane Moriaux and his (less) old Mac already out of date
Jun 23 '07 #3
rf

"Louis" <t0*****@hotmail.comwrote in message
news:KGdfi.8893$tB5.828@edtnps90...
>I have a form with multiple input boxes. I want to validate each input box
(and force user to correct it) before allowing user to move to another,
either using tab key or a mouse click.
What a horrible sounding form.

--
Richard.
Jun 24 '07 #4

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

Similar topics

5
by: The Plankmeister | last post by:
Hi... What's the best method of validating input characters? I would like to prevent users submitting exotic characters (such as those acquired on Windows Systems by pressing ALT+) and thought...
21
by: AnnMarie | last post by:
<script language="JavaScript" type="text/javascript"> <!-- function validate(theForm) { var validity = true; // assume valid if(frmComments.name.value=='' && validity == true) { alert('Your...
3
by: Itai | last post by:
I have an aspx file named index.aspx which contains two ‘form' sections, one that has the runat=server attribute (e.g From1) and one which is a regular HTML form (e.g SignInForm). I am trying...
0
by: Bradley Bossard via DotNetMonster.com | last post by:
I am having an issue with the .NET framework (or C#) and validating events. I have implemented several validating event handlers for textboxes on a form. When I run the app, the form works...
0
by: Joe | last post by:
Hi For a while now I have been finding postings of problems with the validating event not firing on controls properly. I too had this problem. The event would fire when clicking on another...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
1
by: runway27 | last post by:
i have 3 pages page1.php page2.php and page3.php in page1.php user fills a registration form in page2.php the user can review what they have entered and make any changes and page3.php...
3
by: William Gill | last post by:
I have decided that Since I have to update the processing on many of my forms, I'm going to start them all over from scratch. Before I begin I thought I'd solicit comments on using the PHP regex...
7
by: Thiago Macedo | last post by:
Hi again, folks. i'm developing a windows application that gets data from an Mysql database through PHP server-side scripts. I'm not totally familiar with Requests and XML on .Net 2.0. I'll...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
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,...
0
jinu1996
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 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.