473,399 Members | 3,603 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,399 software developers and data experts.

field.focus() Problem

190 100+
i have written following code for for checking required field .

Expand|Select|Wrap|Line Numbers
  1. function validate_required(field,alerttxt)
  2. {
  3. with (field)
  4. {
  5. if (value==null||value=="")
  6. {alert(alerttxt);
  7. focus();
  8. return false;}
  9. else {return true}
  10. }
  11. }
but fucus() is not working .......
Kindly help ASP
Dec 7 '08 #1
4 1265
acoder
16,027 Expert Mod 8TB
Don't use with. Just use the field directly: field.focus().
Dec 7 '08 #2
Shalini Bhalla
190 100+
Still it not works . I have aready tried
Dec 8 '08 #3
acoder
16,027 Expert Mod 8TB
OK, how are you calling the function? Post a snippet of code.
Dec 8 '08 #4
clain
79
hey give an id to the element you want to focus. now use this construct

Expand|Select|Wrap|Line Numbers
  1. document.getElementById('id_of_your_element').focus()
  2.  
this will fix your problem.. if it does not fix.i will personally fix it for you..

enjoy coding/!!!
Dec 9 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: 'bonehead | last post by:
Greetings, I'm still something of a newbie to html/php/mysql. I have a php/html form with several fields of type "input". If the user enters improper data in a particular field and clicks the...
2
by: Wai Man Chung | last post by:
Dear all, I have an asp page which upon opening a field will be set to be in focus so that user can type in data without the need to use the mouse to click on the field. However, after I add...
2
by: fish | last post by:
Hi, I have an HTML page with a FORM and some input fields. On the fields I wish to do validation as the punters change the field values. If they get it wrong, then I tell them and then wish...
2
by: nntp-service.ohio-state.edu | last post by:
Hey folks - I'm a newbie to java script. I'm trying to make a portable data-validator for fields in an HTML form. Ideally, it would work something like this: <input type="text" name="test"...
7
by: Mike | last post by:
I've been trying for the past week to put a simple code together. I have done a LOT of searching, found scripts showing the functions I would like to use, however when I mix them it all goes wrong,...
7
by: JW | last post by:
hello everybody I've got the following problem. I'm writing a form and I'm using javascript to validate fields (i.e. numeric, not blank). When my scripts detects an error I want it to put the...
3
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There...
4
by: bienwell | last post by:
Hi, I have a problem and really need your help. In my web page ASPX, I have some text fields to accept data from users. I did form validation like this : <td class="dataTD" style="HEIGHT:...
5
by: Stuart | last post by:
Hi all, Iv'e got a page that has a mass amount of input fields, all of which require a decimal figure. To make it easier when it comes to inputting data, I'm trying to setup + and - links that...
4
by: vozzek | last post by:
(bad joke, I know) Alright, I'm an almost total java rookie, so please don't laugh (a snicker or chuckle would be okay I guess...) I've got a form (newloginform) with an E-mail field...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.