Adding JavaScript Validation on ASP.NET Textbox

J

JJ_377

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_TextChanged",
"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.
 
J

JJ_377

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.
 
S

Steve C. Orr [MVP, MCSD]

It definitely sounds like some custom code would be needed to fit your
somewhat unique requirements.
 
J

JJ_377

Yes. I am surprised that it is unique. I suspect/hope things will look
quite different 10 year from now.
J.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,614
Members
45,292
Latest member
EttaCasill

Latest Threads

Top