473,698 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding JavaScript Validation on ASP.NET Textbox

I want a JavaScript validation function to fire on an ASP.NET textbox's
change event.

Here's what I've been trying and it is not working. The following added
in the webform's page load event:

txtBirthdate.At tributes.Add("t xtBirthdate_Tex tChanged",
"MyJSFunction() ")

txtBirthdate.At tributes.Add("T extChanged", "MyJSFunction() ")

txtBirthdate.At tributes.Add("o nchange", "MyJSFunction() ")

txtBirthdate.At tributes.Add("o nChange", "MyJSFunction() ")

I've been usual a simliar construct sucessfully with .net hyperlinks:

hlSSN.Attribute s.Add("onclick" ,
"openMessageWin dow('../Information.htm ')")

Thank you very much.

Nov 19 '05 #1
5 2581
I suggest you customize one of the validation controls.
This article shows you how:
http://SteveOrr.net/articles/Validation.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
<JJ****@hotmail .com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
I want a JavaScript validation function to fire on an ASP.NET textbox's
change event.

Here's what I've been trying and it is not working. The following added
in the webform's page load event:

txtBirthdate.At tributes.Add("t xtBirthdate_Tex tChanged",
"MyJSFunction() ")

txtBirthdate.At tributes.Add("T extChanged", "MyJSFunction() ")

txtBirthdate.At tributes.Add("o nchange", "MyJSFunction() ")

txtBirthdate.At tributes.Add("o nChange", "MyJSFunction() ")

I've been usual a simliar construct sucessfully with .net hyperlinks:

hlSSN.Attribute s.Add("onclick" ,
"openMessageWin dow('../Information.htm ')")

Thank you very much.

Nov 19 '05 #2
Thank you very much. I will review with great interest and expectation.
J.

Nov 19 '05 #3
Also...

I am wondering if you can recommend a resource or an approach to
validating international telephone and address info.

I note that while .NET features validators for distinct entities --
such as a French phone number OR a German phone number -- there is no
control for validating a phone number which in theory could be entered
by a user from any country. I note that the .net validators are
designed for European countries, and of them, only very few are
represented...

I had thought about creating a custom validator that would run through
the countries I could define, but is this really the best way to do
things when in theory, each country could feature a very distinct phone
number format. The same question concerns me regarding postal codes.

?

Thank you again for any and all.

J.

Nov 19 '05 #4
It definitely sounds like some custom code would be needed to fit your
somewhat unique requirements.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

<JJ****@hotmail .com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Also...

I am wondering if you can recommend a resource or an approach to
validating international telephone and address info.

I note that while .NET features validators for distinct entities --
such as a French phone number OR a German phone number -- there is no
control for validating a phone number which in theory could be entered
by a user from any country. I note that the .net validators are
designed for European countries, and of them, only very few are
represented...

I had thought about creating a custom validator that would run through
the countries I could define, but is this really the best way to do
things when in theory, each country could feature a very distinct phone
number format. The same question concerns me regarding postal codes.

?

Thank you again for any and all.

J.

Nov 19 '05 #5
Yes. I am surprised that it is unique. I suspect/hope things will look
quite different 10 year from now.
J.

Nov 19 '05 #6

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

Similar topics

3
1753
by: Ronan Dodworth | last post by:
Hi there I'm having a little bit of a problem with my customvalidator control. The problem is the javascript runs fine on my local webserver IIS but not when I post it to the web hosting server. As it is client side scripting I'm suprised that this is the case as I'm using the same browser IE6 and the same machine to access both. I've included the code below. Can anyone help . I've tried lowering all the security settings for intranet...
2
4850
by: D Sheldon | last post by:
I am creating a server control that adds web controls (i.e. textboxes, etc) to a form. I use HtmlTable to build the table and insert the controls. Now I want to add validators to the textbox. Here is the code that I am using bool lastnamerequired=false public bool LastNameRequire get{return lastnamerequired; set{lastnamerequired = value; if(lastnamerequired
1
4722
by: Jack | last post by:
Hi, I have a page with a repeater control that contains textboxes. I'm trying to create a validation class that is called by my page. A method in this class iterates through all the controls on the page. On encountering a TextBox control, it looks at the ID to discern the field the TextBox represents, and then creates the appropriate validation controls and adds them to the page. The controlToValidate property of each validation...
1
2853
by: MattB | last post by:
I have a page with dual controls for a person to enter their height and weight. The dual controls are for English and metric units, and Javascript onChange events handle populating the other control when one if filled. This works well. I also have some asp.net validation controls to make sure the values entered are within certain limits. The problem I'm having is that if I fill in my weight in the Lbs. TextBox, the Javascript fires and...
3
6923
by: Newcomsas | last post by:
Hello, I'm trying to solve a problem with JS textbox array without success. I have two buttons in my page: PLUS and MINUS; at every click on PLUS a new textbox named 'dear' is generated. So, if one clicks, say, 3 times the output is something like: dear dear dear
1
5270
by: cemcat | last post by:
Hello, We have an ASP.NET 2.0 (C#) web form that contains a textbox for users to enter multiple e-mail addresses separated by semicolons. We need to validate that each individual e-mail address entered is a valid e-mail address format. We've added a CustomValidator to perform this validation. We have the server-side validation working fine, but now we need to add some client-side validation via JavaScript. We are having difficulties...
1
1953
by: karen987 | last post by:
I have a comment form, on a news website, ASP page, which users fill in and it adds comments to a news article. The reader clicks on a headline and the comments open up in a new window. It already has server side validation in but i want to add some client side javascript validation. How can do i this when there is alreay a "returnvalidate comment()" in? The only two fields i want to validate are "subject" and "comment" since the rest are drawn...
4
1217
by: Andy B | last post by:
How do you add javascript to a page from codebehind? I have a method I am working on that has a few conditions in it: 1. if either 1 or both WordTextBox or DefinitionTextBox is empty, show a popup window telling the user that the textbox(s) can't be empty and return them to the page with no further action. 2. The value in WordTextBox is already in the collection as a key, so show a popup telling the user that the word already exists and...
0
1060
by: Garudzo | last post by:
I am developing an application using the gridview. the last column is a total column I want to compare the typed in value to the sum of values in the rest of the cells. I tried to use custom validation but the textboxes that contain the values are not seen by the application below is my validation code Protected Sub validateTotals(ByVal source As Object, _ ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) _ ...
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
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
9170
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
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
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...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4372
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
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.