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

Home Posts Topics Members FAQ

form validating function

mk
Please, check the source of my test page: http://tnij.org/mytest
Why is it working is such a stupid way in IE and Opera ? I just want to
display alert when field is blurred and it has no value entered and than I
want JS to execute function focus() on that field. I want not to allow user
to leave the field empty once he enters that field. Hope you know what I
mean, look in the source. It works ok in Forefox only. Warning to IE and
Opera users: you'll have to use ctrl+alt+del to close your browser if you
blur any field :(

Regards,
mk
Apr 12 '06 #1
10 1150
mk

Użytkownik "Lee" <RE**************@cox.net> napisał w wiadomo¶ci
news:e1*********@drn.newsguy.com...
That's expected behavior.
I don't understand at all why but ok, I believe you :)
It's only one of the reasons why you should never try this sort
of validation on blur.


So, how do you suggest to solve the validation ?

Thanks for reply,
mk
Apr 12 '06 #2
mk wrote:
It's only one of the reasons why you should never try this sort
of validation on blur.

So, how do you suggest to solve the validation ?


Use onChange instead of onBlur.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Apr 12 '06 #3
mk wrote:
Użytkownik "Lee" <RE**************@cox.net> napisał w wiadomo¶ci
news:e1*********@drn.newsguy.com...

[...]
It's only one of the reasons why you should never try this sort
of validation on blur.

So, how do you suggest to solve the validation ?


Write error messages to fields in the page, don't use alerts.
--
Rob
Apr 12 '06 #4
mk

Uzytkownik "RobG" <rg***@iinet.net.au> napisal w wiadomosci
news:44***********************@per-qv1-newsreader-01.iinet.net.au...
Write error messages to fields in the page, don't use alerts.


You mean server side validation ? Of course, I'll do this too.

mk
Apr 12 '06 #5
mk wrote:
Uzytkownik "RobG" <rg***@iinet.net.au> napisal w wiadomosci
news:44***********************@per-qv1-newsreader-01.iinet.net.au...
Write error messages to fields in the page, don't use alerts.

You mean server side validation ? Of course, I'll do this too.


Of course do server side validation. But your client script should not use
alerts, it should write messages to the page.
--
Rob
Apr 12 '06 #6
RobG wrote:
mk wrote:
[...] "RobG" [wrote]:
Write error messages to fields in the page, don't use alerts.

You mean server side validation ? Of course, I'll do this too.


Of course do server side validation. But your client script should not
use alerts, it should write messages to the page.


Wrong as it is. The script could attempt to use DOM methods to modify the
document, but if this fails, window.alert() is a most widely supported
fallback. Unfortunately, it cannot be detected reliably when DOM access
fails.

Therefore, I don't see your point in calling window.alert() generally a Bad
Thing. It certainly is an ennerving Bad Thing if used onblur, but I can
see nothing wrong in using it onsubmit, for example.
PointedEars
Apr 14 '06 #7

"mk" <no****@wp.pl> wrote in message news:e1*********@news.onet.pl...
Please, check the source of my test page: http://tnij.org/mytest
Why is it working is such a stupid way in IE and Opera ? I just want to
display alert when field is blurred and it has no value entered and than I
want JS to execute function focus() on that field. I want not to allow user to leave the field empty once he enters that field. Hope you know what I
mean, look in the source. It works ok in Forefox only. Warning to IE and
Opera users: you'll have to use ctrl+alt+del to close your browser if you
blur any field :(

Regards,
mk


you could change the background color to get the user's attention if she
leaves it blank:
<input
onchange="this.style.backgroundColor=(this.value== '')?'yellow':'white';" />
Apr 14 '06 #8
Thomas 'PointedEars' Lahn said the following on 4/14/2006 7:16 AM:
RobG wrote:
mk wrote:
[...] "RobG" [wrote]:
Write error messages to fields in the page, don't use alerts.

You mean server side validation ? Of course, I'll do this too. Of course do server side validation. But your client script should not
use alerts, it should write messages to the page.


Wrong as it is.


But it is good advice, not wrong advice.
The script could attempt to use DOM methods to modify the document, but
if this fails, window.alert() is a most widely supported fallback.
Unfortunately, it cannot be detected reliably when DOM access fails.
alerts are as annoying as popups and are subject to some popup blockers.
Therefore, I don't see your point in calling window.alert() generally a Bad
Thing.
He called it a "Bad Thing" because it is a Bad Thing.
It certainly is an ennerving Bad Thing if used onblur, but I can
see nothing wrong in using it onsubmit, for example.


Never been in an endless loop of alerts then have you?

Besides, any site that alerts me to tell me I have something wrong, I
view source and do a submit() on the form. Screw'em.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 14 '06 #9

"mk" <no****@wp.pl> wrote in message news:e1*********@news.onet.pl...
Please, check the source of my test page: http://tnij.org/mytest
Why is it working is such a stupid way in IE and Opera ? I just want to
display alert when field is blurred and it has no value entered and than I
want JS to execute function focus() on that field. I want not to allow user to leave the field empty once he enters that field. Hope you know what I
mean, look in the source. It works ok in Forefox only. Warning to IE and
Opera users: you'll have to use ctrl+alt+del to close your browser if you
blur any field :(


One strategy would be to put a message (like "Field Required") right next to
the text box, in bold and red, and in a span tag with the visibility style
set to 'hidden'. Then use an onchange event to run code that checks the
value, and if the field is empty, set the visibility of the message span to
visible - else set it to hidden.
If you really want to annnoy the user, make it blink. - anything but those
darn alerts.
Hal
Apr 15 '06 #10
JRS: In article <%Z*************@bignews2.bellsouth.net>, dated Fri, 14
Apr 2006 16:57:45 remote, seen in news:comp.lang.javascript, Hal Rosser
<hm******@bellsouth.net> posted :
you could change the background color to get the user's attention if she
leaves it blank:
<input
onchange="this.style.backgroundColor=(this.value= ='')?'yellow':'white';" />


IMHO, that could be in breach of disability access legislation, since
some who can manage ordinary text may not be able to discriminate
between white and yellow - particularly on a display where yellow is
feeble.

Reminds me of someone who used a yellow highlighter to mark, on a Xerox
copy of an A-Z page, a route through back streets. Unfortunately, those
streets had Sodium lights ...

Perhaps the best approach would be to use a simulated pop-up - a block
of the page itself which might normally be empty, but shows ostentatious
error messages at need.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
Apr 15 '06 #11

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

Similar topics

1
by: AnnMarie | last post by:
Can someone let me know why my phone validation doesn't work within my validate function. It works alone, but not within this function like the other validations do. Phone is not required, but...
6
by: francisco lopez | last post by:
ok , first of all sorry if my english is not so good, I do my best. here is my problem: I don´t know much javascript so I wrote a very simple one to validate a form I have on my webpage. ...
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...
14
by: JNariss | last post by:
Hello, I am fairly new to asp and jscript and am now in the process of learning some form validation. I am taking one step at a time by validating each field and testing it before moving onto...
4
by: easoftware | last post by:
I am using VS .Net 2003 and VB. I have an app with one parent and two Mdi child forms. I need to validate data in the Mdi form. The Form.Validating event works when I try to close a Mdi form,...
27
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...
0
by: Michel Reij | last post by:
I have created a small recorder application in dotnet that records my actions in Internet Explorer into a replayable simulation. For this I have registered the mshtml.DocumentEvents2 class. It...
7
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
3
uranuskid
by: uranuskid | last post by:
Hey folks, I was going to include a contact form on my website. Well, in the first place that seemed an easy thing to do with a form that prompts a PHP file validating the input vaiables and using...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
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...
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...
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...
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
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.