By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,292 Members | 1,381 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,292 IT Pros & Developers. It's quick & easy.

Adding JavaScript Validation on ASP.NET Textbox

P: n/a
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.Attributes.Add("txtBirthdate_TextChan ged",
"MyJSFunction()")

txtBirthdate.Attributes.Add("TextChanged", "MyJSFunction()")

txtBirthdate.Attributes.Add("onchange", "MyJSFunction()")

txtBirthdate.Attributes.Add("onChange", "MyJSFunction()")

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

hlSSN.Attributes.Add("onclick",
"openMessageWindow('../Information.htm')")

Thank you very much.

Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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.googlegr oups.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.Attributes.Add("txtBirthdate_TextChan ged",
"MyJSFunction()")

txtBirthdate.Attributes.Add("TextChanged", "MyJSFunction()")

txtBirthdate.Attributes.Add("onchange", "MyJSFunction()")

txtBirthdate.Attributes.Add("onChange", "MyJSFunction()")

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

hlSSN.Attributes.Add("onclick",
"openMessageWindow('../Information.htm')")

Thank you very much.

Nov 19 '05 #2

P: n/a
Thank you very much. I will review with great interest and expectation.
J.

Nov 19 '05 #3

P: n/a
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

P: n/a
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.googlegr oups.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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.