ASPNET_8
asked on
Javascript Question
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
and
what would be the javascript code to check the alphanumeric data
thanks
try with onKeyDown event...
<script type="text/javascript">
function callFunction() {
//function code here....
}
</script>
like...
<input type="text" onKeyDown="javascript:call Function() " />
<script type="text/javascript">
function callFunction() {
//function code here....
}
</script>
like...
<input type="text" onKeyDown="javascript:call
For Alphanumaric
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 136px; POSITION: absolute; TOP: 136px"
runat="server" onchange = " alphanumeric(this.value)"> </asp:Text Box>
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>
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 136px; POSITION: absolute; TOP: 136px"
runat="server" onchange = " alphanumeric(this.value)">
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>
ASKER
For Alphanumaric
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 136px; POSITION: absolute; TOP: 136px"
runat="server" onchange = " alphanumeric(this.value)"> </asp:Text Box>
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""
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 136px; POSITION: absolute; TOP: 136px"
runat="server" onchange = " alphanumeric(this.value)">
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""
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Its not working I have tried twice
ASKER
Good
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 136px; POSITION: absolute; TOP: 136px"
runat="server" onchange = " alert('test')"></asp:TextB