View Single Post
  #4 (permalink)  
Old January 8th, 2008, 09:49 AM
dhruthi.ram99 dhruthi.ram99 is offline
Registered User
 
Join Date: May 2007
Location: Mysore, Karnataka, India.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, friends thanks for the reply.
Still iam unable to achive for writing the code for Phone No Validation.

Here user can enter either 10 digit number(which starts from 9) OR can enter 8 digit number(starts with 2).

following is my code.


-------------------------

<html>
<head>
<title></title>

<script language="javascript">
function Validate()
{
        var x = document.sform.phone_no.value;
        if(isNaN(x)|| x.indexOf(" ")!=-1){
              alert("Enter numeric value");return false; }
        if (x.length > 10 || x.length > 8 ){
                alert("enter 10 or 8 characters"); return false;
           }
        if (x.charAt(0)!="9" || x.charAt(0)!="2"){
                alert("it should start with 9 or 2 ");
                return false
           }
}
</head>
<body>
<table width="290" height="83" border="0" bgcolor="#F4FAFF">
    <form name="sform" action="search_phone.jsp" method="post">
      <tr class="smallfont">
        <td width="247" height="24" align="center" valign="middle" class="table_header">New Appointment </td>
        <td align="left" valign="middle">&nbsp;</td>
      </tr>

      <tr class="smallfont">
        <td height="26" align="left" valign="middle"><span class="style4">Phone Number
          <input name="phone_no" type="text" id="phone_no" />
        </span></td>
        <td width="33" align="left" valign="middle"><input type="submit" name="Submit" value="Go" onclick="return Validate()"/></td>
      </tr>
      <tr class="smallfont">
        <td height="25" align="left" valign="middle">&nbsp;</td>
        <td align="left" valign="middle">&nbsp;</td>
      </tr>
    </form>
  </table>
</body>
</html>


-------------------------------------


But This code is not working in my place.
Is there any way

Regards,
Dhruthi




Reply With Quote