?
Solved

Javascript Question

Posted on 2011-09-08
7
Medium Priority
?
180 Views
Last Modified: 2012-05-12
How would i call a javascript function on the ontextchanged event of a text box in asp.net
and
what would be the javascript code to check the alphanumeric data

thanks
0
Comment
Question by:ASPNET_8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 36501496
this will call javascript function on the ontextchanged event of a text box in asp.net



<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 136px; POSITION: absolute; TOP: 136px"
                        runat="server" onchange = " alert('test')"></asp:TextBox>
0
 
LVL 13

Expert Comment

by:ansudhindra
ID: 36501503
try with onKeyDown event...

<script type="text/javascript">
function callFunction() {
    //function code here....
}
</script>
like...
<input type="text" onKeyDown="javascript:callFunction()" />

0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 36501511
For Alphanumaric


<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 136px; POSITION: absolute; TOP: 136px"
                        runat="server" onchange = " alphanumeric(this.value)"></asp:TextBox>


Javascript function


      <script type="text/javascript">
function alphanumeric(alphane)
{
      var numaric = alphane;
      for(var j=0; j<numaric.length; j++)
            {
              var alphaa = numaric.charAt(j);
              var hh = alphaa.charCodeAt(0);
              if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
              {
              }
            else      {
                         alert("Your Alpha Numeric Test Failed");
                   return false;
              }
             }
 alert("Your Alpha Numeric Test Passed");
 return true;
}
</script>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ASPNET_8
ID: 36501554
For Alphanumaric


<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 136px; POSITION: absolute; TOP: 136px"
                        runat="server" onchange = " alphanumeric(this.value)"></asp:TextBox>


Javascript function


      <script type="text/javascript">
function alphanumeric(alphane)
{
      var numaric = alphane;
      for(var j=0; j<numaric.length; j++)
            {
              var alphaa = numaric.charAt(j);
              var hh = alphaa.charCodeAt(0);
              if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
              {
              }
            else      {
                         alert("Your Alpha Numeric Test Failed");
                   return false;
              }
             }
 alert("Your Alpha Numeric Test Passed");
 return true;
}
</script>

this code is showing the error


""microsoft jscript runtime error object expected""
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 1500 total points
ID: 36501570
Its wprking finr for me

try this

      <asp:TextBox id="TextBox1"       runat="server" onchange = " alphanumeric()"></asp:TextBox>


Javascript function


        <script type="text/javascript">
function alphanumeric()
{
      var numaric = document.getElementById("TextBox1").value ;
      for(var j=0; j<numaric.length; j++)
            {
              var alphaa = numaric.charAt(j);
              var hh = alphaa.charCodeAt(0);
              if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
              {
              }
            else      {
                         alert("Your Alpha Numeric Test Failed");
                   return false;
              }
             }
 alert("Your Alpha Numeric Test Passed");
 return true;
}
</script>
0
 

Author Comment

by:ASPNET_8
ID: 36501603
Its not working I have tried twice
0
 

Author Closing Comment

by:ASPNET_8
ID: 36901593
Good
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question