473,385 Members | 2,069 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,385 software developers and data experts.

client side validation with asp:TextBox ???

Hello,

I have a textbox in which I only want to display numbers when the
focus is set on the textbox and the user presses a key on the kb.
Easy with html-control <input id="htmlTxtVal2" type="text"
onkeypress="return NoNumbers(event)" and javascript (implement the
onkeypres event handler)

But how to implement it when using the asp:TextBox control ?
Seems to me that a validation control doesn't work 'cause validation
is only performed when the user clicks the send-button, and NOT when
the user is still entering the information in the textbox.

So, how?

thank you
Chris
Jul 14 '08 #1
2 1996
"Christian Cambier" <ch***************@gmail.comwrote in message
news:9f**********************************@e39g2000 hsf.googlegroups.com...
I have a textbox in which I only want to display numbers when the
focus is set on the textbox and the user presses a key on the kb.
Easy with html-control <input id="htmlTxtVal2" type="text"
onkeypress="return NoNumbers(event)" and javascript (implement the
onkeypres event handler)

But how to implement it when using the asp:TextBox control ?
MyTextBox.Attributes.Add("onkeypress", "return NoNumbers(event);");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 14 '08 #2
On Jul 14, 5:58 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"Christian Cambier" <christian.camb...@gmail.comwrote in message

news:9f**********************************@e39g2000 hsf.googlegroups.com...
I have a textbox in which I only want to display numbers when the
focus is set on the textbox and the user presses a key on the kb.
Easy with html-control <input id="htmlTxtVal2" type="text"
onkeypress="return NoNumbers(event)" and javascript (implement the
onkeypres event handler)
But how to implement it when using the asp:TextBox control ?

MyTextBox.Attributes.Add("onkeypress", "return NoNumbers(event);");

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
thank you for the great tip!

Chris
Jul 14 '08 #3

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

Similar topics

6
by: Alex | last post by:
I am a newbie to ASP.NET... What I was trying to do... but yet to succeed in... I am building a customer info database... and on default, I want to display the customer's basic information in...
2
by: Matthew Wieder | last post by:
Hi - I'm trying to do client-side validation of the text in a Asp.Net textbox control using javascript. My page has the following: <form id="Form1" method="post" runat="server" onsubmit="return...
2
by: Kerri | last post by:
Hi, I have an asp textbox that allows users to enter their password. I have another page that allows a user to edit their user account. On this page I set the text to be the password in...
1
by: Shilpi Chaudhry | last post by:
I have a forloop which I use to create textboxes - but unfortunately all of them have the same ids - I need to assign different ids to these textboxes creeated in the loop so that I can retrieve...
0
by: Luis Esteban Valencia | last post by:
am trying to databind within an asp:textbox control. I have tried many variations found here but nothing seems to work. It works fine if I use a regular HTML textbox input though. Here is what I...
3
by: Patrick | last post by:
Try to put in a TextBox next month's date in format (MMM yyyy). The following does NOT work, why is that? <!--When rendered, the texbox is blank, although the text in the round bracket after the...
0
by: datakix | last post by:
After 16 hours of frustration, I've managed to solve this problem for a project I'm working on. The 'trick' is set EnableViewState="False" for the asp:textbox inside the Repeater control. The...
2
by: VMI | last post by:
In the Page_Load() of my webForm, I have the following code, and on my HTML button, the onclick button calls writeVal() (the javascript function). When I click on the button, I see the messagebox...
0
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.