473,408 Members | 2,839 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,408 software developers and data experts.

Javascript Quickie

i have a custom validator control that fires on the text changed event of a
field, but the validator wont fire when the field is blank, so i was looking
at using a bit of clientside script.

i not the hottest at Javascript, so i was wondering how i would go about
checking if a field has been populated and if then then returning the focus
to that field if it hasnt

Cheers,
Craig
Nov 19 '05 #1
3 980
would it be possible to add it in as an attribute on that field?

txtCsa_No.Attributes.Add("onblur", "then do a field length check and return
the focus if less than 0??;")

"Craig G" <craig.gamble@y_arrasoftware.com> wrote in message
news:uQ*************@TK2MSFTNGP12.phx.gbl...
i have a custom validator control that fires on the text changed event of a field, but the validator wont fire when the field is blank, so i was looking at using a bit of clientside script.

i not the hottest at Javascript, so i was wondering how i would go about
checking if a field has been populated and if then then returning the focus to that field if it hasnt

Cheers,
Craig

Nov 19 '05 #2
Craig G wrote:
would it be possible to add it in as an attribute on that field?

txtCsa_No.Attributes.Add("onblur", "then do a field length check and return
the focus if less than 0??;")


Be careful with "onBlur" in combination with setting focus:
you might end up with two fields combatting for the focus
and blocking the browser:
fieldA isn't correct and pulls the focus
to it, which fires the onBlur for fieldB. FieldB isn't satisfied
either so pulls the focus to itself, thereby firing the onBlur
for fieldA and starting the loop again. Been there, done that :-)
--
Hans Kesting
Nov 19 '05 #3
should be ok that way as this field is the only field that has an onblur
event

any idea's on what i need to write into the string in the attribute?

Cheers,
Craig

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Craig G wrote:
would it be possible to add it in as an attribute on that field?

txtCsa_No.Attributes.Add("onblur", "then do a field length check and return the focus if less than 0??;")


Be careful with "onBlur" in combination with setting focus:
you might end up with two fields combatting for the focus
and blocking the browser:
fieldA isn't correct and pulls the focus
to it, which fires the onBlur for fieldB. FieldB isn't satisfied
either so pulls the focus to itself, thereby firing the onBlur
for fieldA and starting the loop again. Been there, done that :-)
--
Hans Kesting

Nov 19 '05 #4

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

Similar topics

6
by: Vishant | last post by:
Hi, I'm new to javascript and regEx and trying to solve the following problem. I have a function which validates the password if there is a number:...
4
by: Colin Graham | last post by:
Hi guys, Just a quickie here that i hope someone can help me with. Basically i want stop the user from closing the popup window using the small x button in the top right hand corner. Im aware...
7
by: Robin Haswell | last post by:
Hey guys. This should just be a quickie: I can't figure out how to convert r"\x2019" to an int - could someone give me a hand please? Cheers -Rob
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:
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
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.