473,382 Members | 1,431 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,382 software developers and data experts.

How do I make a form field take focus ?

I want to make a form field take focus ideally coded in the form :-

<form method="post" action="index.php?action=newname">
<input type="text" name="name" size="40" value="" />
<input type="submit" name="submit" value="Create" />
</form>

Many thanks in advance,

Aaron
Jan 22 '08 #1
3 2642
Aaron Gray said the following on 1/21/2008 10:22 PM:
I want to make a form field take focus ideally coded in the form :-

<form method="post" action="index.php?action=newname">
<input type="text" name="name" size="40" value="" />
<input type="submit" name="submit" value="Create" />
</form>
comp.infosystems.www.authoring.html

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 22 '08 #2
Randy Webb a écrit :
It is easy to prove me wrong though. Post a script that will determine
if an arbitrary form element can be focused or not.

<input type="text" onfocus="this.blur()" name="inputYouCantFocus">
There is too many way allowing us to hide and/or prevent the focus on an
element, let me add a few to the list.

1) the obvious <input type="hidden">

2) <input disabled="disabled">

3) <input style="opacity:0">

4) <input style="position:absolute;clip:rect(0,0,0,0)">

5)
<div style="overflow:hidden;width:0;height:0">
<input>
</div>

6)
<div style="position:absolute;z-index:1;width:300px;height:100px">
<input style="width:100px">
</div>
<div style="position:absolute;z-index:2;width:300px;height:100px;
background-color:red"></div>

7) with this one, the focus can occur only with a mouse. You got a
keyboard only, you are screwed and can't focus it at all. How a script
would be able to determine if the second input is focusable ?
<input>
<input tabindex="-1">

and many many more tricky ways to hide anything we want.
Happy scripting!
:D

--
laurent
Jan 23 '08 #3
Laurent vilday said the following on 1/23/2008 8:29 AM:
Randy Webb a écrit :
>It is easy to prove me wrong though. Post a script that will determine
if an arbitrary form element can be focused or not.

<input type="text" onfocus="this.blur()" name="inputYouCantFocus">

There is too many way allowing us to hide and/or prevent the focus on an
element, let me add a few to the list.
Look through the thread I posted a URL to. It has a lot of examples of
inputs that can't have focus.
1) the obvious <input type="hidden">

2) <input disabled="disabled">

3) <input style="opacity:0">

4) <input style="position:absolute;clip:rect(0,0,0,0)">

5)
<div style="overflow:hidden;width:0;height:0">
<input>
</div>

6)
<div style="position:absolute;z-index:1;width:300px;height:100px">
<input style="width:100px">
</div>
<div style="position:absolute;z-index:2;width:300px;height:100px;
background-color:red"></div>

7) with this one, the focus can occur only with a mouse. You got a
keyboard only, you are screwed and can't focus it at all. How a script
would be able to determine if the second input is focusable ?
<input>
<input tabindex="-1">

and many many more tricky ways to hide anything we want.
style="visibility: none"
style="display: none"

But, just one is all it takes to show that you can't determine it with
script to prove that it is impossible.

I am curious to see his attempt at it. His last one failed miserably.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 23 '08 #4

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

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: JJ | last post by:
Hi All, When someone selects a value in a select on a form I want to show the same form with another select with certain values depending on first select. How can I do this? Should I keep...
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...
1
by: Cooper | last post by:
Hello, i have a form with TEXT, SELECT etc, elements. Simple, i suppose two TEXT (name: T1 and T2). If a user insert a bad value, it display a error message and turn back at form. My problem is:...
6
by: Charles Banas | last post by:
weird subject - i hope more than just one curious regular will hear me out. :) ok, i've got a bit of a big problem, and i need answers as soon as possible. i know this forum is meant for web...
4
by: Semi Head | last post by:
Hello folks, I'm looking for a script to validate a specific number value in a standard form input field. An example would be, if someone enters a number into a form input, I want the script to...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
1
by: tdmailbox | last post by:
Is there a vb command that can tell me if I have focus in the child or parent form? Basicly I have a search macro that needs me to have focus to any field in the parent form. If my focus is set...
4
by: GTi | last post by:
Is it possible to have a generic script that set the input focus on the first valid element in a document (not hidden or disabled) ? This script is at the end of a document, but don't work. ...
8
by: M.L. | last post by:
Hello. I created a form using JS validation with the form tag as follows: <form name="form1" action="dynaform.php" method="post" onsubmit="return pvg_sub();"> The js validation script sends...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: 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...

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.