Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

focus() doesn't work

Status
Not open for further replies.

lucyc

Programmer
Mar 1, 2002
62
US
Hi,

I try to set the focus back to a field on which user enter an invalid value, but it doesn't work. Can anyone help??? Thanks. Here is my code :
Function Validate()
dim item
set myform=document.forms("frmCSB")
For each item in document.forms(0)
ITname=item.name
Suffix=right(item.name,2)
if Suffix = "MM" then
if not IsNumeric(item.value) then
msgbox "Please enter a number between 1 and 12."
myform.item.name.focus <=== set focus to field
.............................
 
try this...
Code:
myform.item.focus
Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
I tried and it doesn't work. thanks.
 
Hmm, it seems to work for me just fine:
Code:
<html>
<head>
<script language=&quot;VBScript&quot;>
Function checkit
	checkit = true
	If Not isNumeric(frmWhatever.txtFocus.value) Then
		frmWhatever.txtFocus.focus
		checkit = false
	End If
End Function
</script>
</head>
<body>
<form name=&quot;frmWhatever&quot;>
<input type=&quot;text&quot; name=&quot;txtFocus&quot;>
<input type=&quot;button&quot; onClick=&quot;msgbox(checkit)&quot; value=&quot;Check Me&quot;>
</form>
</body>
</html>

-Tarwn ________________________________________________
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top