/    Sign up×
Community /Pin to ProfileBookmark

Hi,
My wife has a form people fill out to submit orders.
Have a check on it to validate the fields and this works ok and if field not completed it returns the focus to the input field that failed as wanted.
When the user has scrolled to the bottom of the page off the field validated it returns to the input field but the title of the field is above out of view.
Is there a way to return to the focus field and display the page the line above that so the title shows?

my current code is
if((field.type==”text” || field.type==”textarea” || field.type==”password”) && field.value==””){
alert(“Please fill in the ‘”+field.name+ “‘ field.”)
setTimeout(“document.forms[0].elements[“+i+”].focus()”, 10)
return false
}

thanks
Rab

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Zero-x252Aug 07.2003 — try using a <span> tag around the title and using the same code just make the focus the span... but to do this you would have to make it much more complex probably by using o say

focus(field.name + '1')

where the span is

<span name="name1">text</span>

and the field is

<input type="text" name="name">
Copy linkTweet thisAlerts:
@rab_denverauthorAug 07.2003 — Thanks for the response,

I've tried your suggestion but may be doing it wrong but always positions the first row as the input field.

I'll try some tomorrow.

thanks again
×

Success!

Help @rab_denver 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 6.13,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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