Adding JavaScript Validation on ASP.NET Textbox

  • Thread starter Thread starter JJ_377
  • Start date Start date
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.
 
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.
 
It definitely sounds like some custom code would be needed to fit your
somewhat unique requirements.
 
Yes. I am surprised that it is unique. I suspect/hope things will look
quite different 10 year from now.
J.
 
Back
Top