title: CGPA OR GPA field validation using javascript function
body: <p>I am facing problems in java script validation in asp.net. The validation is simple but somehow it is not working.</p>
  
  <p>I try the below code..</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="gpavalidation._Default" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;script&gt;
          function gpa()
          {
              var reg = /[0-9][.][0-9]/;
              if(!reg.test(document.getElementById("cgpa").value))
              {
                  return false;
              }
              else
              {
                  return true;
                  alert("correct value");
  
              }
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
          GPA:&lt;input type="text" name="cgpa" id="cgpa" maxlength="3" onclick="return gpa();" /&gt;
          &lt;input type="submit" name="name" value="submit " /&gt;
  
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But it is not working...</p>
  
  <p><strong>What i want:</strong>  I want that when user put data in the gpa filed then the data is only in numeric format like 3.4 or 4.0 or 2.1 something like that...
  How to get the result like that..</p>
  
  <p>Any help will be appreciated.</p>