• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Cross browser issues

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone point me to a good resource for writing javascript that functions in both IE and Netscape version 4 and up? I have studied documents and tutorials until I'm half blind, but even the simplest code seems to fail our QA testing.
I've done a simple form validation using onBlur() as recommended in all the javascript tutorials I've seen. I am testing only that the text box is not blank, but it still seems to cause an infinite loop in some versions of Netscape 4+. I tried using onChange(), but sometimes this prevents form submission completely IE!
None of these effects happen with any regularity. Three out of 5 textboxes work fine, two cause loops in Netscape. 9 times out of 10 the form submits in IE, but occasionally it will refuse to submit even though the text box is correctly filled out....
I'm just looking for a simple form validation that works in all versions all the time. Can anyone help?
Kat
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
**All the time**??
People will disable javascript (I do) -- so nothing works all the time. Also, have you considered Opera, lynx (yes people do you it, not many, but some), Macs, UNIX, etc.
Bottom line is that javascript is a dog at the best of times, anything you do on the client, you *must* do on the server as well -- so why bother with javascript validation at all?
James
 
kat luna
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why bother with javascript?
because I'm *just* the web developer (better known here as art school dropout) and the "Developers" insist that all validation be done client-side before the data is returned to the servlet.
I have repeatedly suggested that javascript is a light weight programming language and too dependent on browser versions/settings/etc to be reliable, but the response is "find a way to do it." So I'm here asking for help. The only book I have on Javascript was written for Navigator 2.0 and most of the web tutorials I've looked at are from 1999.
Can anyone recommend anything (books/URL's) that has information on Javascripting for version 4.0 - 6.0 browsers? Please?
Thanks.
Kat
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Q: why bother using javascript?
A:
You tel me what do you do if you don't have server to store you pages? how you gonna use CGI, Cold Fusion well, database ?
There are millions of questions that you will never be able to answer. Javascript remains the only option in this case.
-=A=-

Originally posted by James Hobson:
**All the time**??
People will disable javascript (I do) -- so nothing works all the time. Also, have you considered Opera, lynx (yes people do you it, not many, but some), Macs, UNIX, etc.
Bottom line is that javascript is a dog at the best of times, anything you do on the client, you *must* do on the server as well -- so why bother with javascript validation at all?
James


 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have always done form validation in JavaScript in the onSubmit() event handler of the form.
There are annoying differences in the way browsers decide to fire events, and I always get caught with trying to use onBlur/onFocus combination.
Here is some cross-browser JavaScript for simple form validation, it has a nice set of trim methods for checking if a text field is blank (the form is validated via onSubmit() ).

So unless there is a specific need for you to do form validation with onBlur/onFocus combination (or if you don't mind writing different versions of the code for different browsers (nasty), I would avoid it.
James.
 
kat luna
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by james swan:
So unless there is a specific need for you to do form validation with onBlur/onFocus combination (or if you don't mind writing different versions of the code for different browsers (nasty), I would avoid it.
James.[/B]


Hi and thanks for the suggestions. Sadly, our design document says that there MUST be item-by-item validation on each form, not just on form submit.
I have narrowed the problem down to the fact that in Netscape, tabbing out of a textbox places the cursor in the next form object before onBlur() of the previous fires and that is why I am getting an alert loop. (blank textboxB loses focus to display the alert for blank textboxA -- which in turn triggers an alert for blank textboxB which triggers alert for blank textboxA etc...)
In short, I still am at a loss as to how to do item by item validation in Netscape. onChange() avoids the alert loop, but it doesn't fire if the user simply tabs past the textbox without entering any data.
Anyone else have done this successfully?
Thanks in advance,
kat
 
James Hobson
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amit, the question was:
-- so why bother with javascript <em>validation</em> at all?
If you **really** need something to work (if you are an enterprise for example) then javascript is unsafe -- fact.
If you dont have a server, or database etc. then I expect you dont have enterprise needs and so you can rely on javascript.
Javascript has a place, for making rollovers, for highly graphical design over content sites. But for hard core, every mistake costs us a million dollars type work, it simply isnt good enough, use it in addition to server side logic, but dont rely on it.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello kat luna, since some people are rather rude here, I will point you to the best online javascript forum on the net. There we are very friendly and helpfull and people know a solution to everything unlike here. The link is http://www.wsabstract.com
Go there and ask your question, and you should have a responce in less then 2 hours
hope this gets you the answer you want.
A1
 
You can thank my dental hygienist for my untimely aliveness. So tiny:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic