jquery for textbox with one decimal point

jquery for textbox with one decimal point

Hi i am new to jquery.And i am assigned with the task now that my textbox has to accept integer values and float values.For floating numbers only one number has to be typed after the decimal point.I tried this code but it didn't work for me.i think my problem is with regex.Please suggest me some solution.

  1. $("input.cctxt").keypress(function (evt){ 

  2.       var theNum = $("input.cctxt").val();
  3.     // var regExp = /^\d{0,}\.\d{2}$/;    //format  .## required
  4.         var regExp = "/^\d+(\.\d+)?$/";  //format #.## required
  5.         var formatLine = theNum.match(regExp);
  6.         console.log(formatLine);
  7.         if(!formatLine) //Test if there was no match
  8.         console.log("enter number correctly");
  9. });
This is what i have done yet