How to restrict user to enter only numbers in webtextfield

Here I want to restrict user to enter only numbers in webtextfield. I have written javascript for that but it works on mac but not on windows.
Javascript code is


  dim setjavasript(1) as String
  setjavasript(0) = txtCardNumber.ControlID
 Select Case Session.Browser
  Case WebSession.BrowserType.Firefox
    dim aa as new WebTextArea 
     aa.AppendText "  $('#" +txtCardNumber.ControlID + "').keydown(function(e)"+EndOfLine
    aa.AppendText " { var allow_key_codes = ['1','2','3','4','5','6','7','8','9','0','.']; "+EndOfLine
    aa.AppendText" if (( $.inArray(e.key  , allow_key_codes) < 0)&&(e.keyCode!=8) )"+EndOfLine
    aa.AppendText" {   e.preventDefault(); } "+EndOfLine
    aa.AppendText" else { "+EndOfLine
    aa.AppendText" var len = document.getElementById('"+txtCardNumber.ControlID +"_inner"+"'); "+EndOfLine
      aa.AppendText"if((len.value.length==16)&& (e.keyCode!=8)){"+EndOfLine
    aa.AppendText"  e.preventDefault();}"
    aa.AppendText" } }) ; "
    ExecuteJavaScript(aa.Text)
     Else
    dim aa as new WebTextArea 
    aa.AppendText "  $('#" +txtCardNumber.ControlID + "').keypress(function(e)"+EndOfLine
    aa.AppendText " { var allow_key_codes = [8,46,48,49,50,51,52,53,54,55,56,57,110]; "+EndOfLine
    aa.AppendText" if ( $.inArray(e.keyCode  , allow_key_codes) < 0 )"+EndOfLine
    aa.AppendText" {   e.preventDefault(); } "+EndOfLine
    aa.AppendText" else { "+EndOfLine
    aa.AppendText" var len = document.getElementById('"+txtCardNumber.ControlID +"_inner"+"'); "+EndOfLine
    aa.AppendText"  if((len.value.length==2) && (e.keyCode!=8)){"+EndOfLine
    aa.AppendText "{len.value = len.value + '.';}} "+EndOfLine
    aa.AppendText"if((len.value.length==5)&& (e.keyCode!=8)){"+EndOfLine
    aa.AppendText"  e.preventDefault();}"+EndOfLine
    aa.AppendText"if(((len.value.split('.').length-1)>0)&&(e.keyCode==46)){"+EndOfLine
    aa.AppendText" e.preventDefault();"+EndOfLine
    aa.AppendText"}"+EndOfLine
      aa.AppendText" } }) ; "
    ExecuteJavaScript(aa.Text)
      End Select

It gives error and web application gets shut down and i have wriiten code at open event of webpage. Can any one help me ??

Check with Bob Keeney. We have a subclass of WebTextField that only allows numbers without using jQuery or the need to check which browser it is.

We’ve not made this public yet. Haven’t decided on a price for the source yet either. Contact me at support at bkeeney.com if you’re interested.