Solved

Javascript Question

Posted on 2011-09-08
7
177 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
Technology Partners: 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 500 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

Technology Partners: 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!

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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