Where did u add the script exactly?, in aspx file or as a seperate JS file or injected/registered via code behind?..did u check whether the script is being rendered to the client?..did u hook it to an event(s) properly?..if its in a JS file then did u add
reference to it in aspx?
I really dont expect u to answer these to me...if something is wrong with scripts then I ask these questions to myself :)
U could check whether its rendering or not on page requests by using developer tool (if u r using IE/Chrome)/firebug (if u r using Firefox)
hi friends
i have placed script in my coding (i.e.,) in aspx
function isNumeric(e) {
var c == getKeyCode(e);
if (c !== 8 && (c < 48 || c > 57)) {
return false;
}
return true;
}
hi friends
i have placed script in my coding (i.e.,) in aspx
function isNumeric(e) {
var c == getKeyCode(e);
if (c !== 8 && (c < 48 || c > 57)) {
return false;
}
return true;
}
it depends on what is the implmentation of getKeyCode function
the method of getting entered key value is different in browsers like IE and firefox.... it might be that the code used in this function is not compatible with the browser u r testing in...
try to replace the function with this code....
function isNumeric(eventObj)
{
var keycode;
if(eventObj.keyCode) //For IE
keycode = eventObj.keyCode;
else if(eventObj.Which)
keycode = eventObj.Which; // For FireFox
else
keycode = eventObj.charCode; // Other Browser
if (keycode!=8) //if the key is the backspace key
{
if (keycode<48||keycode>57) //if not a number
return false; // disable key press
else
return true; // enable key press
}
}
Priyanka R
Member
109 Points
167 Posts
Script is not working in IE
Mar 01, 2012 10:41 AM|LINK
i have placed the script in my coding. script is not working... can any one sugest..
vish02chouha...
Member
303 Points
251 Posts
Re: Script is not working in IE
Mar 01, 2012 10:47 AM|LINK
Oh welcome on the asp.net,
Priyanka you have to ellaborate your question properly,
If you taking about the javascript then It is browser dependent,
please clear the senerio by which we can help you
Ramesh T
Contributor
5079 Points
821 Posts
Re: Script is not working in IE
Mar 01, 2012 10:49 AM|LINK
Where did u add the script exactly?, in aspx file or as a seperate JS file or injected/registered via code behind?..did u check whether the script is being rendered to the client?..did u hook it to an event(s) properly?..if its in a JS file then did u add reference to it in aspx?
I really dont expect u to answer these to me...if something is wrong with scripts then I ask these questions to myself :)
U could check whether its rendering or not on page requests by using developer tool (if u r using IE/Chrome)/firebug (if u r using Firefox)
Priyanka R
Member
109 Points
167 Posts
Re: Script is not working in IE
Mar 01, 2012 11:05 AM|LINK
hi friends
i have placed script in my coding (i.e.,) in aspx
function isNumeric(e) {
var c == getKeyCode(e);
if (c !== 8 && (c < 48 || c > 57)) {
return false;
}
return true;
}
<asp:TextBox ID="txt_numeric" runat="server" MaxLength="2" onkeypress="return isNumeric(this)"Width="50px"></asp:TextBox>
script to check numeric is not working....
Ramesh T
Contributor
5079 Points
821 Posts
Re: Script is not working in IE
Mar 01, 2012 11:18 AM|LINK
Please replace ur textbox control with (u should pass the event obj. as parameter to isNumeric method and not the textbox itself)
Everything else looks okay to me apart from 'getKeyCode' function, is it an another custom funtion?
Cheers,
R
vish02chouha...
Member
303 Points
251 Posts
Re: Script is not working in IE
Mar 01, 2012 11:22 AM|LINK
function isNumeric(e) { var c=e.keyCode? e.keyCode : e.charCode if (c !== 8 && (c < 48 || c > 57)) { return false; } return true; } <asp:TextBox ID="txt_numeric" runat="server" MaxLength="2" onkeypress="return isNumeric(event)" Width="50px"></asp:TextBox>kedarrkulkar...
All-Star
34013 Points
5468 Posts
Re: Script is not working in IE
Mar 01, 2012 11:34 AM|LINK
it depends on what is the implmentation of getKeyCode function
the method of getting entered key value is different in browsers like IE and firefox.... it might be that the code used in this function is not compatible with the browser u r testing in...
try to replace the function with this code....
function isNumeric(eventObj) { var keycode; if(eventObj.keyCode) //For IE keycode = eventObj.keyCode; else if(eventObj.Which) keycode = eventObj.Which; // For FireFox else keycode = eventObj.charCode; // Other Browser if (keycode!=8) //if the key is the backspace key { if (keycode<48||keycode>57) //if not a number return false; // disable key press else return true; // enable key press } }http://www.mindfiresolutions.com/Numeric-validation-using-Javascript-612.php
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
jbkumar
Participant
1522 Points
295 Posts
Re: Script is not working in IE
Mar 01, 2012 01:50 PM|LINK
Change your code as below mentioned
1.
function isNumeric(e) {
var c = getKeyCode(e);
if (c != 8 && (c < 48 || c > 57)) {
return false;
}
return true;
}
<asp:TextBox ID="txt_numeric" runat="server" MaxLength="2" onkeypress="return isNumeric(this);" Width="50px"></asp:TextBox>
or for checking numeric values simply use below mentioned code in your design
2.
<asp:TextBox ID="txt_numeric" runat="server" MaxLength="2" onkeyup="this.value=this.value.replace(/[^0-9]/,'');" Width="50px"></asp:TextBox>
Hope it helps you!!
Happy Coding !!!
Priyanka R
Member
109 Points
167 Posts
Re: Script is not working in IE
Mar 02, 2012 04:43 AM|LINK
Thanks friends it helps me lot