/    Sign up×
Community /Pin to ProfileBookmark

Setting focus to a field as soon as page opens

Dear all,

I want that as soon as i open my page typing URL in the browser address bar. Focus should automatically set to a desired text-box.

can anyone help me out.

Regards,

Vinay

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 06.2005 — onload=function(){document.forms['formName'].elements['inputName'].focus();}
Copy linkTweet thisAlerts:
@NileshXYZMay 06.2005 — BTW you should put that above code in the body tag.

for example

<body onload="document.formName.fieldName.focus();">
Copy linkTweet thisAlerts:
@FangMay 06.2005 — BTW you should put that above code in the body tag.

for example

<body onload="document.formName.fieldName.focus();">[/QUOTE]

No, place it in an external JavaScript file. Separate functionality from content.
Copy linkTweet thisAlerts:
@vinayauthorMay 07.2005 — Dear all,

Firstly thank you for providing this solution i.e.

onload="document.FORM1.invoiceno.focus();" in body tag.

i have provided a check to see that the focused textbox should not be empty and if it is empty user would we given an alert message.but the problem is, if i click the maximize, minimize or even close button, the message pops-up. i want that the alert message should not fire if user clicks on close, minimize and maximize button.


regards,

vinay
Copy linkTweet thisAlerts:
@FangMay 07.2005 — what code have you used to fire the alert?
Copy linkTweet thisAlerts:
@vinayauthorMay 09.2005 — Dear all,

I have set the focus to a particular text box as soon as form loads. On the "onBlur " Event i have written a code that checks whether the field is empty or not, if empty an alert saying Field cannot be empty is fired. But this fires even when i click the close "X" button or maximize or minimize button.

Hope you understood.

Regards,

Vinay
×

Success!

Help @vinay spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...