473,804 Members | 3,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Set focus on the field (Form validation in ASP.NET)

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: 30px" width="100">
<asp:TextBox id="txtFUEL_ISS UED1" style="Z-INDEX: 100; POSITION: absolute"
runat="server" Width="107px" BorderColor="Tr ansparent"
autoPostback="t rue"
OnTextChanged=" txtFUEL_ISSUED1 _TextChanged"></asp:TextBox>
</td>

<td class="dataTD" style="HEIGHT: 30px" width="100">
<asp:CompareVal idator id="CompareVali dator1"
runat="server" Width="90px" ControlToValida te="txtFUEL_ISS UED1"
ForeColor="Ligh tCoral" ErrorMessage="P lease enter a number!"
Operator="DataT ypeCheck" Type="Double"></asp:CompareVali dator>
</td>
In the txtFUEL_ISSUED1 _TextChanged, I checked if data on this field is valid
or not. If it's valid then I add this value in the TOTAL field. I'd to to
set focus on the next field when this data IS VALID, OR focus on this field
when data IS NOT valid . Can you help me ? Thanks in advance
Dec 1 '05 #1
4 2587
I suggest you upgrade to ASP.NET 2.0, which has new features that satisfy
all your requests.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"bienwell" <bi******@hotma il.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
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: 30px" width="100">
<asp:TextBox id="txtFUEL_ISS UED1" style="Z-INDEX: 100; POSITION:
absolute" runat="server" Width="107px" BorderColor="Tr ansparent"
autoPostback="t rue"
OnTextChanged=" txtFUEL_ISSUED1 _TextChanged"></asp:TextBox>
</td>

<td class="dataTD" style="HEIGHT: 30px" width="100">
<asp:CompareVal idator id="CompareVali dator1"
runat="server" Width="90px" ControlToValida te="txtFUEL_ISS UED1"
ForeColor="Ligh tCoral" ErrorMessage="P lease enter a number!"
Operator="DataT ypeCheck" Type="Double"></asp:CompareVali dator>
</td>
In the txtFUEL_ISSUED1 _TextChanged, I checked if data on this field is
valid or not. If it's valid then I add this value in the TOTAL field. I'd
to to set focus on the next field when this data IS VALID, OR focus on
this field when data IS NOT valid . Can you help me ? Thanks in advance

Dec 2 '05 #2
Steve,

I have some questions:

1- There are some versions ASP.NET 2.0 from the www.asp.net web site :
a- .NET Framework 2.0 SDK x86,
b- .NET Framework Version 2.0 Redistributable Package (x86)
c- .NET Framework 2.0 SDK x64
d- .NET Framework Version 2.0 Redistributable Package x64 (64
Bit)
e- .NET Framework 2.0 SDK IA64
f- .NET Framework Version 2.0 Redistributable Package IA64
(64 Bit)

Which one do you suggest me to download ?

2- After downloading, do you think this code will work OR I should
change something ?

Sub txtFUEL_ISSUED1 _TextChanged(se nder As Object, e As EventArgs)
Dim strScript As String = "<script language=JavaSc ript>"

If IsNumeric(txtFU EL_ISSUED1.text ) OR
txtFUEL_ISSUED1 .text="" Then
Dim aValue as double=0.0
If IsNumeric(txtFU EL_ISSUED1.text ) Then
aValue=CDBL(txt FUEL_ISSUED1.Te xt)
End If

' ADD the value to the TOTAL field
ViewState("FUEL _ISSUED_Total") =
ViewState("FUEL _ISSUED_Total") + aValue - ViewState("FUEL _ISSUED1")
txtFUEL_ISSUED_ Total.text=Form atNumber(ViewSt ate("FUEL_ISSUE D_Total"),
2, , ,TriState.True)
ViewState("FUEL _ISSUED1") = aValue

strScript = strScript &
"document.form1 .txtFUEL_ISSUED 2.focus();" 'FOCUS on the next field

Else 'FOCUS on the current field
strScript = strScript &
"document.form1 .txtFUEL_ISSUED 1.focus();"
End If

strScript = strScript & "<" & "/script>"
If (Not Page.IsStartupS criptRegistered ("clientScript" )) Then
Page.RegisterSt artupScript("cl ientScript", strScript)
End If

End Sub

=============== =============== =============== ======
"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I suggest you upgrade to ASP.NET 2.0, which has new features that satisfy
all your requests.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"bienwell" <bi******@hotma il.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
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: 30px" width="100">
<asp:TextBox id="txtFUEL_ISS UED1" style="Z-INDEX: 100; POSITION:
absolute" runat="server" Width="107px" BorderColor="Tr ansparent"
autoPostback="t rue"
OnTextChanged=" txtFUEL_ISSUED1 _TextChanged"></asp:TextBox>
</td>

<td class="dataTD" style="HEIGHT: 30px" width="100">
<asp:CompareVal idator id="CompareVali dator1"
runat="server" Width="90px" ControlToValida te="txtFUEL_ISS UED1"
ForeColor="Ligh tCoral" ErrorMessage="P lease enter a number!"
Operator="DataT ypeCheck" Type="Double"></asp:CompareVali dator>
</td>
In the txtFUEL_ISSUED1 _TextChanged, I checked if data on this field is
valid or not. If it's valid then I add this value in the TOTAL field. I'd
to to set focus on the next field when this data IS VALID, OR focus on
this field when data IS NOT valid . Can you help me ? Thanks in advance


Dec 2 '05 #3
If you have a 32-bit machine ( a standard Intel or AMD )...

If you want the very minimum necessary to run ASP.NET 2.0,
get .NET Framework Version 2.0 Redistributable Package (x86)
If you want the QuickStart Tutorials, extra tools *and* ASP.NET 2.0,
get .NET Framework 2.0 SDK x86

If you have a 64-bit machine, your choice may vary depending on the cpu.

The code you posted should run on any of the 5 choices.

Juan T. Llibre
ASP.NET.FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
=============== =============== ========

"bienwell" <bi******@hotma il.com> wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Steve,

I have some questions:

1- There are some versions ASP.NET 2.0 from the www.asp.net web site :
a- .NET Framework 2.0 SDK x86,
b- .NET Framework Version 2.0 Redistributable Package (x86)
c- .NET Framework 2.0 SDK x64
d- .NET Framework Version 2.0 Redistributable Package x64 (64 Bit)
e- .NET Framework 2.0 SDK IA64
f- .NET Framework Version 2.0 Redistributable Package IA64 (64 Bit)

Which one do you suggest me to download ?

2- After downloading, do you think this code will work OR I should change something ?

Sub txtFUEL_ISSUED1 _TextChanged(se nder As Object, e As EventArgs)
Dim strScript As String = "<script language=JavaSc ript>"

If IsNumeric(txtFU EL_ISSUED1.text ) OR txtFUEL_ISSUED1 .text="" Then
Dim aValue as double=0.0
If IsNumeric(txtFU EL_ISSUED1.text ) Then
aValue=CDBL(txt FUEL_ISSUED1.Te xt)
End If

' ADD the value to the TOTAL field
ViewState("FUEL _ISSUED_Total") = ViewState("FUEL _ISSUED_Total") + aValue -
ViewState("FUEL _ISSUED1")
txtFUEL_ISSUED_ Total.text=Form atNumber(ViewSt ate("FUEL_ISSUE D_Total"), 2, ,
,TriState.True)
ViewState("FUEL _ISSUED1") = aValue

strScript = strScript & "document.form1 .txtFUEL_ISSUED 2.focus();"
'FOCUS on the next field

Else 'FOCUS on the current field
strScript = strScript & "document.form1 .txtFUEL_ISSUED 1.focus();"
End If

strScript = strScript & "<" & "/script>"
If (Not Page.IsStartupS criptRegistered ("clientScript" )) Then
Page.RegisterSt artupScript("cl ientScript", strScript)
End If

End Sub
=============== =============== =============== ====== "Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I suggest you upgrade to ASP.NET 2.0, which has new features that satisfy all your requests.


Dec 2 '05 #4
Thank you very much for your advices.

bienwell
=============== ===============
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:eZ******** *****@TK2MSFTNG P09.phx.gbl...
If you have a 32-bit machine ( a standard Intel or AMD )...

If you want the very minimum necessary to run ASP.NET 2.0,
get .NET Framework Version 2.0 Redistributable Package (x86)
If you want the QuickStart Tutorials, extra tools *and* ASP.NET 2.0,
get .NET Framework 2.0 SDK x86

If you have a 64-bit machine, your choice may vary depending on the cpu.

The code you posted should run on any of the 5 choices.

Juan T. Llibre
ASP.NET.FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
=============== =============== ========

"bienwell" <bi******@hotma il.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Steve,

I have some questions:

1- There are some versions ASP.NET 2.0 from the www.asp.net web site
:
a- .NET Framework 2.0 SDK x86,
b- .NET Framework Version 2.0 Redistributable Package (x86)
c- .NET Framework 2.0 SDK x64
d- .NET Framework Version 2.0 Redistributable Package x64
(64 Bit)
e- .NET Framework 2.0 SDK IA64
f- .NET Framework Version 2.0 Redistributable Package IA64
(64 Bit)

Which one do you suggest me to download ?

2- After downloading, do you think this code will work OR I should
change something ?

Sub txtFUEL_ISSUED1 _TextChanged(se nder As Object, e As EventArgs)
Dim strScript As String = "<script language=JavaSc ript>"

If IsNumeric(txtFU EL_ISSUED1.text ) OR
txtFUEL_ISSUED1 .text="" Then
Dim aValue as double=0.0
If IsNumeric(txtFU EL_ISSUED1.text ) Then
aValue=CDBL(txt FUEL_ISSUED1.Te xt)
End If

' ADD the value to the TOTAL field
ViewState("FUEL _ISSUED_Total") =
ViewState("FUEL _ISSUED_Total") + aValue - ViewState("FUEL _ISSUED1")

txtFUEL_ISSUED_ Total.text=Form atNumber(ViewSt ate("FUEL_ISSUE D_Total"), 2,
, ,TriState.True)
ViewState("FUEL _ISSUED1") = aValue

strScript = strScript &
"document.form1 .txtFUEL_ISSUED 2.focus();" 'FOCUS on the next field

Else 'FOCUS on the current field
strScript = strScript &
"document.form1 .txtFUEL_ISSUED 1.focus();"
End If

strScript = strScript & "<" & "/script>"
If (Not Page.IsStartupS criptRegistered ("clientScript" )) Then
Page.RegisterSt artupScript("cl ientScript",
strScript)
End If

End Sub
=============== =============== =============== ======

"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I suggest you upgrade to ASP.NET 2.0, which has new features that satisfy
all your requests.


Dec 2 '05 #5

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

Similar topics

5
28145
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 Submit button, the php script has to trap it and return a javascript error message box with an OK button. That part I've already got down. But, you know how in Visual Basic you can set the focus on the offending
2
14301
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 to put the focus back to the offending field. ( It works if a use an 'onblur' event but not an 'onchange' )
3
5376
by: Dan | last post by:
This function validates a price field on my form. It fires with onchange. If the validation fails, I want the focus to return to the same field so that the user can correct it. The way it is working now, the focus moves to whichever field is clicked upon exiting this field. The behavior is the same in ie,ns and opera. This is probably simple, but I don't understand why this doesn't work Any ideas would be much appreciated. Thanks. ...
10
6724
by: CES | last post by:
All, I'm having a problem returning focus back to an input field in Netscape. The code works in IE and Opera but not in netscape6+. Basically I have a function that is called upon exiting a form field, if the
4
2223
by: Nitin | last post by:
Hi I have created function to check date and time. at the time of execution, if date is left empty the function returns the error message but then the focus goes to next field. Next filed is for time and there is also a check on that. If time is empty return error message. Again the explorer returns error message and then shifts the focus to date field, again error message and focus goes to time and this story goes on and on, untill...
5
11383
by: tshad | last post by:
I have a date validation function that I want to stay at the object I am validating if there is a Validation error, but it always goes to the next object. The Javascript: function ValidateForm(me){ var dt=me if (isDate(dt.value)==false){ dt.focus()
3
8321
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 are a couple of people selling components... but that is not really an option for me... So, I took the plunge and modified the "WebUIValidation.js" file to make it happen... After tracing through file, I figure it out. It was actually pretty...
3
5420
by: Patrick [MSFT] | last post by:
Let me preface this with the goal I'm trying to achieve is mimic a feature of another language (Dexterity used by Microsoft Dynamics) and so while a filling a drop down list is a workable solution I'd rather do it like Microsoft Dynamics does and use separate textbox and lookup button. What I have is, simply, is a C# winform, a textbox and a pushbutton. On the textbox, on the validating event of the textbox I check my customer table...
0
9584
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10583
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9160
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.