Solved

Javascript Question

Posted on 2011-09-08
7
173 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
  • 3
  • 3
7 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
Comment Utility
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
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:ASPNET_8
Comment Utility
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
Comment Utility
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
Comment Utility
Its not working I have tried twice
0
 

Author Closing Comment

by:ASPNET_8
Comment Utility
Good
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now