Javascript not firing in a datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've got this great wee function which strips out the spaces entered into a
textbox and it does this on the key press off a user. I got this working in a
test application no problem however when I went to intergrate it with my real
application which has the textbox in the footer of a datagrid the javascript
doesn't seem to run. Has anyone any idea why this is not working for me?

Any help would be much appreciated. Thanks

Here is the function and the textbox which I'm using

<script language="javascript" type="text/javascript">

<script language="javascript" type="text/javascript">
function CheckValidAdd(textbox, val)
{
val = val.replace(/[^0-9a-zA-Z]/g, '');
textbox.value = val;
}

</script>
<FooterTemplate>
<asp:TextBox ID="add_NINo" onKeyUp="CheckValidAdd(add_NINo,
add_NINo.value);" Columns="5" Runat="Server" />
</FooterTemplate>
 
Hi Stephen,

When you run the page look at the HTML output. Does the id of the textbox
match the value you are sending to the CheckValidAdd function?

If not, I would look at adding the call to the javascript function using the
control.attributes.add method.

HTH
 
Back
Top