Jump to content

[SOLVED] conversion of vb function into javascript...


rsammy

Recommended Posts

i have this function in vb. i need to use it in javascript on a php page. how can i do it?

 

Private Function validPIN() As Boolean
    ' PIN is exactly 10 digits numeric only string
    Dim txtPIN As String
    
    txtPIN = Trim(pin_txt.Text)
    If Len(txtPIN) = 10 And IsNumeric(txtPIN) Then
        ' 1/12/2007 - Perform the CDV Digit Check
        Dim totDoubleOdd As Long
        Dim totEven As Long
        Dim totPIN As Long
        Dim cdvPINdigit As Long
        ' Use double-add-double algorithm for odd numbered digits
        Dim i As Long
        Dim j As Long
                
        i = 1
        totDoubleOdd = 0
        For i = 1 To 9 Step 2
            j = 2 * CLng(Mid(txtPIN, i, 1))
            If j > 9 Then
                totDoubleOdd = totDoubleOdd + (j - 9)
            Else
                totDoubleOdd = totDoubleOdd + j
            End If
        Next
        
        ' Now add Even and calculate totPIN
        totEven = CLng(Mid(txtPIN, 2, 1)) + CLng(Mid(txtPIN, 4, 1)) + CLng(Mid(txtPIN, 6, 1)) + CLng(Mid(txtPIN, 8, 1))
        totPIN = 24 + totDoubleOdd + totEven
        cdvPINdigit = totPIN Mod 10
        If cdvPINdigit > 0 Then
            cdvPINdigit = 10 - cdvPINdigit
        End If
        ' Check against last digit of PIN
        If Right(txtPIN, 1) = CStr(cdvPINdigit) Then
            validPIN = True     ' Success
        Else
            MsgBox "PIN Check Digit Failure - Verify your PIN and re-enter", vbOKOnly
        End If
    Else
        MsgBox "Please enter a valid PIN - Exactly 10 digits numeric string only", vbOKOnly
    End If
End Function

 

thanxxxxxx

I think you should just translate it to PHP and call it in a form or something no need for javascript and If you want it in PHP just translate it line by line

 

I did this not sure if it works.. not tested

 

function validPIN($pin_txt) { //As Boolean {
    // PIN is exactly 10 digits numeric only string
    $txtPIN;
    
    $txtPIN = trim($pin_txt)
    if(strlen($txtPIN) = 10 And is_numeric($txtPIN)) {
        // 1/12/2007 - Perform the CDV Digit Check
        $totDoubleOdd;
        $totEven;
        $totPIN;
        $cdvPINdigit;
        // Use double-add-double algorithm for odd numbered digits
        $i;
        $j;
                
        $i = 1
        $totDoubleOdd = 0
        for($i = 1; $i = 9; $i+= 2){
            $j = 2 * substr($txtPIN, $i, 1)
            if($j > 9) {
                $totDoubleOdd = $totDoubleOdd + ($j - 9)
            } else {
                $totDoubleOdd = $totDoubleOdd + $j
            }
        }
        
        // Now add Even and calculate totPIN
        $totEven = substr($txtPIN, 2, 1) + substr($txtPIN, 4, 1) + substr($txtPIN, 6, 1) + substr($txtPIN, 8, 1)
        $totPIN = 24 + $totDoubleOdd + $totEven
        $cdvPINdigit = $totPIN % 10
        if($cdvPINdigit > 0) {
            $cdvPINdigit = 10 - $cdvPINdigit
        }
        // Check against last digit of PIN
        if(substr($txtPIN, -1) = $cdvPINdigit) {
            //$validPIN = True;     ' Success
    return True;
        } else {
            echo "PIN Check Digit Failure - Verify your PIN and re-enter"; //, vbOKOnly
	    return False;
        }
    } else {
        echo "Please enter a valid PIN - Exactly 10 digits numeric string only"; //, vbOKOnly
    }
} //End Function

thanx a lot for ur reply!

 

now, my question is.. how do i use this in this text page for the PIN field. how do i call this fucntion for this particular field PIN # field???!!!

 

 

<?PHP

//require_once ("phpInclude/config.php");
require_once ("../config.php");

include ("phpInclude/cookie.php");

if (isset($USER_NAME))

{

list($user_fname, $user_lname) = explode (' ', $USER_NAME);
if ($USER_NAME == ' Office Manager')
{
$query= "SELECT grp_name FROM group_details";
}
else
{
$query= "SELECT grp_name FROM group_details, user_mgr WHERE user_mgr.user_fname='$user_fname' AND user_mgr.user_lname='$user_lname' AND user_mgr.user_grp_id=group_details.grp_id";
}
$result=mysql_query($query);

$row = mysql_fetch_array($result);

$group_name = $row["grp_name"];

}



if($USER_LEVEL != 2)

{

	header("Location: main.php");

	exit;

}



$message = "";

$goodMessage = "";



if (isset($_POST["action"]))

{

	$user_name = $_POST["userName"];

	$pass_word = $_POST["passWord"];

	$security_level = $_POST["securityLevel"];

	$email_address = $_POST["email"];

	$first_name = $_POST["fname"];

	$last_name = $_POST["lname"];

	$home_phone = $_POST["hphone"];

	$mobile_phone = $_POST["mphone"];

	$home_address = $_POST["haddress"];

	$home_city = $_POST["hcity"];

	$home_state = $_POST["hstate"];

	$home_zip = $_POST["hzip"];

	$npi = $_POST["npi"];



	$pass_word = trim($pass_word);

	$pass_word = crypt($pass_word);

	$user_name = trim($user_name);



	$query = "SELECT * FROM user_mgr WHERE  user_logon='$user_name' or user_email='$email_address'";

	$result = mysql_query($query);

	$num_rows = mysql_num_rows($result);

	$row=mysql_fetch_array($result);

	$user_logon=$row["user_logon"];
	$user_email=$row["user_email"];



	if ($num_rows == 0)

	{

		$query = "INSERT INTO user_mgr(user_logon,user_pwd,user_fname,user_lname,user_home_ph,user_work_ph,user_auth,user_email, user_grp_id, wireless)

					 VALUES('$user_name','$pass_word','$first_name','$last_name','$home_phone','$mobile_phone','$security_level','$email_address', '1', 'Yes')";

		mysql_query($query);

		$user_id = mysql_insert_id();
		//echo "$user_id";


		$querys = "INSERT INTO phy_det (phy_fname, phy_lname, phy_home_ph, phy_mobile_ph, phy_pin, phy_email, phy_add, phy_city, phy_state, phy_zip, user_id, phy_disabled, phy_registered_by)
					  VALUES ('$first_name', '$last_name', '$home_phone', '$mobile_phone', '$npi', '$email_address', '$npi', '$user_id' 'Enable', '$userid') ";

		mysql_query($querys);

		//print ("$querys");


		$goodMessage =  $first_name." ".$last_name." has been added to the users database.";

	}

	else

	{

		if($user_logon == $user_name)
		{
		$message = "A Provider with username \"".$user_name."\" is already registered.";
		}
		else
		{
		$message = "An Provider with email address \"".$email_address."\" is already registered.";
		}


	}

}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>ABC</title>

<link rel='stylesheet' type='text/css' href='css/styleSheet.css'>

<SCRIPT language="JavaScript" src="js/tree.js">

</SCRIPT>

<SCRIPT language="JavaScript">

<?PHP

//Navigation File

//require_once ("phpInclude/nav.php");
require_once ("../nav.php");

?>

</SCRIPT>

<script language="JavaScript">

function trim(inputString) {

   // Removes leading and trailing spaces from the passed string. Also

   // removes consecutive spaces and replaces it with one space.

   var retValue = inputString;

   var ch = retValue.substring(0, 1);

   while (ch == " ") { // Check for spaces at the beginning of the string

      retValue = retValue.substring(1, retValue.length);

      ch = retValue.substring(0, 1);

   }

   ch = retValue.substring(retValue.length-1, retValue.length);

   while (ch == " ") { // Check for spaces at the end of the string

      retValue = retValue.substring(0, retValue.length-1);

      ch = retValue.substring(retValue.length-1, retValue.length);

   }

   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string

      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings

   }

   return retValue; // Return the trimmed string back to the user

} // Ends the "trim" function



function validate()
{

 	var err_msg = new Array();

	var i=0;

	var j=0;

	var bigstring = "Please correct the following errors:\n";

	var loginID = "";

	var pass = "";

	var count = 0;

	var aMatch = false;

	var aBlank = false;



 	firstName = document.addPhysician.fname.value;

	lastName = document.addPhysician.lname.value;

	homePhone = document.addPhysician.hphone.value;

	mobilePhone = document.addPhysician.mphone.value;

	zip = document.addPhysician.hzip.value;

	userName = document.addPhysician.userName.value;

	passWord = document.addPhysician.passWord.value;

	confirmPassWord = document.addPhysician.confirmPassWord.value;

	securityLevel = document.addPhysician.securityLevel.value;

	email = document.addPhysician.email.value;

	npi = document.addPhysician.npi.value;



	if (trim(firstName).length < 1)

	{

		 err_msg[i] = "First name cannot be blank.";

		 i++;

	}

	alert("HERE AFTER FIRST NAME");

	if (trim(lastName).length < 1)

	{

		 err_msg[i] = "Last name cannot be blank.";

		 i++;

	}


	if (trim(homePhone).length < 1)

	{

		 err_msg[i] = "Home phone cannot be blank.";

		 i++;

	}

	if (trim(mobilePhone).length < 1)

	{

		 err_msg[i] = "Mobile phone cannot be blank.";

		 i++;

	}

	if (trim(zip).length > 0)
	{
		if(!(validateZIP(zip)))
		{
			err_msg[i] = "Postal Code does not appear to be in the correct format NNNNN or NNNNN-NNNN.";
		 	i++;
		}
	}


 	 if (trim(userName).length<1)

	 {

		   err_msg[i] = "Username cannot be blank.";

		   i++;

	 }


	//PIN Check begins
    	// PIN is exactly 10 digits numeric only string
    	//$txtPIN;

    	$txtPIN = trim($pin)
    	if(strlen($txtPIN) = 10 And is_numeric($txtPIN))
    	{
		// 1/12/2007 - Perform the CDV Digit Check
		$totDoubleOdd;
		$totEven;
		$totPIN;
		$cdvPINdigit;
		// Use double-add-double algorithm for odd numbered digits
		//$i;
		//$j;

		$i = 1
		$totDoubleOdd = 0
        	for($i = 1; $i = 9; $i+= 2)
        	{
			$j = 2 * substr($txtPIN, $i, 1)
			if($j > 9)
			{
				$totDoubleOdd = $totDoubleOdd + ($j - 9)
			}
			else
			{
				$totDoubleOdd = $totDoubleOdd + $j
			}
		}

		// Now add Even and calculate totPIN
		$totEven = substr($txtPIN, 2, 1) + substr($txtPIN, 4, 1) + substr($txtPIN, 6, 1) + substr($txtPIN, 8, 1)
		$totPIN = 24 + $totDoubleOdd + $totEven
		$cdvPINdigit = $totPIN % 10
		if($cdvPINdigit > 0)
		{
			$cdvPINdigit = 10 - $cdvPINdigit
		}
		// Check against last digit of PIN
		if(substr($txtPIN, -1) = $cdvPINdigit)
		{
			//$validPIN = True;     ' Success
			return True;
		}
		else
		{
			echo "PIN Check Digit Failure - Verify your PIN and re-enter"; //, vbOKOnly
			return False;
		}
	}
	else
	{
		echo "Please enter a valid PIN - Exactly 10 digits numeric string only"; //, vbOKOnly
    	}
	//END PIN check

	 if (trim(passWord).length<1)

	 {

		   err_msg[i] = "Password cannot be blank.";

		   i++;

		   aBlank = true;

	 }



	 if (trim(confirmPassWord).length<1)

	 {

		   err_msg[i] = "Confirm password cannot be blank.";

		   i++;

		   aBlank = true;

	 }



	 if(!aBlank)

	{

		if(passWord != confirmPassWord)

		{

			err_msg[i] = "The passwords do not match.";

			i++;

		}

		else

		{

			aMatch = true;

		}

	}



	if(aMatch)

	{

		var theReg = /\d/g;


		if(!(passWord.match(theReg)) || (passWord.length < )
		{
			err_msg[i] = "The password must be at least 8 characters and contain at least one numeric character.";

			i++;

		}

	}


	 if ((securityLevel.length<1))

	 {

		   err_msg[i] = "Select a security level.";

		   i++;

	 }

	 if (trim(email).length<1)

	 {

		   err_msg[i] = "Enter an email address.";

		   i++;

	 }

	 if (i>0)

	 {

		for (j=0; j<err_msg.length; j++) {

			count = j + 1;

			bigstring = bigstring + "\n" + count +". " + err_msg[j];

		}

		alert (bigstring);



		return false;

	}

	else

	{

		return true;

	}


}

function validPIN($pin)  //As Boolean
{
    	// PIN is exactly 10 digits numeric only string
    	$txtPIN;

    	$txtPIN = trim($npi)
    	if(strlen($txtPIN) = 10 And is_numeric($txtPIN))
    	{
		// 1/12/2007 - Perform the CDV Digit Check
		$totDoubleOdd;
		$totEven;
		$totPIN;
		$cdvPINdigit;
		// Use double-add-double algorithm for odd numbered digits
		$i;
		$j;

		$i = 1
		$totDoubleOdd = 0
        	for($i = 1; $i = 9; $i+= 2)
        	{
			$j = 2 * substr($txtPIN, $i, 1)
			if($j > 9)
			{
				$totDoubleOdd = $totDoubleOdd + ($j - 9)
			}
			else
			{
				$totDoubleOdd = $totDoubleOdd + $j
			}
		}

		// Now add Even and calculate totPIN
		$totEven = substr($txtPIN, 2, 1) + substr($txtPIN, 4, 1) + substr($txtPIN, 6, 1) + substr($txtPIN, 8, 1)
		$totPIN = 24 + $totDoubleOdd + $totEven
		$cdvPINdigit = $totPIN % 10
		if($cdvPINdigit > 0)
		{
			$cdvPINdigit = 10 - $cdvPINdigit
		}
		// Check against last digit of PIN
		if(substr($txtPIN, -1) = $cdvPINdigit)
		{
			//$validPIN = True;     ' Success
			return True;
		}
		else
		{
			echo "PIN Check Digit Failure - Verify your PIN and re-enter"; //, vbOKOnly
			return False;
		}
	}
	else
	{
		echo "Please enter a valid PIN - Exactly 10 digits numeric string only"; //, vbOKOnly
    	}
} //End Function

</Script>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin initial case cap
function changeCase(frmObj) {
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = frmObj.value;
strLen = tmpStr.length;
if (strLen > 0)  {
for (index = 0; index < strLen; index++)  {
if (index == 0)  {
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else {
tmpChar = tmpStr.substring(index, index+1);
if (tmpChar == " " && index < (strLen-1))  {
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + tmpChar + postString;
         }
      }
   }
}
frmObj.value = tmpStr;
}
//  End -->

</SCRIPT>

</head>



<BODY onload="window.scroll(0,yoffset)">

<table width="900" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="4" bgcolor="#FFFFFF">
      <div align="left"><font color="#FFFFFF"></font></div>
      <div align="right"><font color="#FFFFFF"><img src="images/title_barom.jpg" width="900" height="69"></font></div></td>
  </tr>
  <tr>
    <td align="left" valign="top" width="300"> <table width="300" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td align="left" valign="top"><div align="center"><font color="#006699"><img src="images/clear.gif" height="15" width="1"><b><?PHP print($group_name); ?><br>
              User: </b><?PHP print($USER_NAME); ?> </font></div></td>
        </tr>
        <tr>
          <td align="left" valign="top"> <SCRIPT language="JavaScript">

   tree.loadState()

   tree.display()

</SCRIPT> </td>
        </tr>
      </table>
<p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><? print("<b>$copyright1</b>"); ?></p>
</td>
    <td colspan="3" align="left" valign="top"> <br> <br> <table width="450" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#006699">
        <tr>
          <td><img src="images/addUser_header.gif" height="17" width="450"></td>
        </tr>
        <tr>
          <td> <table width="450" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td colspan="3"><img src="images/clear.gif" width="1" height="15"></td>
              </tr>
              <tr>
                <td width="15"><img src="images/clear.gif" width="15" height="8"></td>
                <td width="425" align="left" valign="top"> <form name="addPhysician" method="post" action="addPhy.php" onSubmit="return validate()">
                    <table width="421" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="211"><img src="images/clear.gif" width="1" height="15"></td>
                        <td width="210"> </td>
                      </tr>
                      <?PHP

If ((strlen($message) > 0) || (strlen($goodMessage) > 0))

{

?>
                      <tr>
                        <td width="211"> <div align="right">
                            <?PHP

		if(strlen($message) > 0)

		{

	?>
                            <img src="images/errImg.gif" width="30" height="30">
                            <?PHP

		}

		else

		{

	?>
                            <img src="images/goodImg.gif" width="30" height="30">
                            <?PHP

		}

	?>
                          </div></td>
                        <td width="210">
                          <?PHP

		if(strlen($message) > 0)

		{

			print("<font class=\"errTxt\">".$message."</font>");

		}

		else

		{

			print("<font class=\"goodTxt\">".$goodMessage."</font>");

		}



	?>
                        </td>
                      </tr>
                      <tr>
                        <td width="211"> <div align="right"><img src="images/clear.gif" width="1" height="15"></div></td>
                        <td width="210"> </td>
                      </tr>
                      <?PHP

}

?>
                      <tr>
                        <td width="211"> <div align="right"><font class="inputLbl">First
                            Name:  </font></div></td>
                        <td width="210"> <input  class="txtboxLarge"  type="text" name="fname" onBlur="javascript:changeCase(document.addPhysician.fname);">
                          <font class="redTxt">*</font> </td>
                      </tr>
                      <tr>
                        <td width="211"> <div align="right"><font class="inputLbl">Last
                            Name:  </font></div></td>
                        <td width="210"> <input  class="txtboxLarge"  type="text" name="lname" onBlur="javascript:changeCase(document.addPhysician.lname);">
                          <font class="redTxt">*</font> </td>
                      </tr>
                      <tr>
                        <td width="211"> <div align="right"><font class="inputLbl">Home
                            Phone (as 000-000-0000):  </font></div></td>
                        <td width="210"> <input  class="txtboxLarge"  type="text" name="hphone">
                          <font class="redTxt">*</font> </td>
                      </tr>
                          <tr>
                        <td width="211"> <div align="right"><font class="inputLbl">PIN #:  </font></div></td>
                        <td width="210"> <input  class="txtboxLarge" type="text" name="pin>
                          <font class="redTxt">*</font> </td>
                      </tr>
                      <tr>
                        <td width="211"> <div align="right"><font class="inputLbl">Email:  </font></div></td>
                        <td width="210"> <input  class="txtboxLarge" type="text" name="email">
                          <font class="redTxt">*</font> </td>
                      </tr>
                      <tr>
                        <td width="211"> <div align="right"><font class="inputLbl">Username:  </font></div></td>
                        <td width="210"> <input  class="txtboxLarge" type="text" name="userName">
                          <font class="redTxt">*</font> </td>
                      </tr>
                      <tr>
                        <td width="211"> <div align="right"><font class="inputLbl">Password:  </font></div></td>
                        <td width="210"> <input  class="txtboxLarge" type="password" name="passWord">
                          <font class="redTxt">*</font> </td>
                      </tr>
                      <tr>
                        <td width="211"> <div align="right"><font class="inputLbl">Confirm
                            Password:  </font></div></td>
                        <td width="210"> <input  class="txtboxLarge"  type="password" name="confirmPassWord">
                          <font class="redTxt">*</font> </td>
                      </tr>
                      <tr>
                        <td width="211"> <div align="right"><font class="inputLbl">Security
                            Level:  </font></div></td>
                        <td width="210"> <select name="securityLevel">
                            <option value="4" selected>Provider</option>
                          </select> <font class="redTxt">*</font> </td>
                      </tr>
                      <tr>
                        <td width="211"><img src="images/clear.gif" width="1" height="15"></td>
                        <td width="210"> </td>
                      </tr>
                      <tr>
                        <td width="211"> </td>
                        <td width="210"> <input class="sbttn" type="submit" name="action" value="Submit">
                        </td>
                      </tr>
                    </table>
                  </form></td>
                <td width="15"><img src="images/clear.gif" width="15" height="1"></td>
              </tr>
              <tr>
              <tr>
                <td colspan="3"><img src="images/clear.gif" width="1" height="15"></td>
              </tr>
            </table></td>
        </tr>
      </table>
      <p> </p></td>
  </tr>
  <tr>
    <td align="left" valign="top" width="300"> </td>
    <td colspan="3"> </td>
  </tr>
</table>

</body>

</html>

<?PHP

mysql_close();

?>

thanx again.

 

but, i am still stuck.

 

i am trying to do this...

 

function validateNPI(npi)  //As Boolean
{
//NPI Check begins
// PIN is exactly 10 digits numeric only string
//$txtPIN;

$txtPIN = trim($npi);
//  Perform the CDV Digit Check
$totDoubleOdd;
$totEven;
$totPIN;
$cdvPINdigit;
// Use double-add-double algorithm for odd numbered digits
//$i;
//$j;

$i = 1;
$totDoubleOdd = 0;
for($i = 1; $i = 9; $i+= 2)
{
	$j = 2 * substr($txtPIN, $i, 1);
	if($j > 9)
	{
		$totDoubleOdd = $totDoubleOdd + ($j - 9);
	}
	else
	{
		$totDoubleOdd = $totDoubleOdd + $j;
	}
}

// Now add Even and calculate totPIN
$totEven = substr($txtPIN, 2, 1) + substr($txtPIN, 4, 1) + substr($txtPIN, 6, 1) + substr($txtPIN, 8, 1);
$totPIN = 24 + $totDoubleOdd + $totEven;
$cdvPINdigit = $totPIN % 10;
if($cdvPINdigit > 0)
{
	$cdvPINdigit = 10 - $cdvPINdigit;
}
// Check against last digit of PIN
if(substr($txtPIN, -1) = $cdvPINdigit)
{
	//$validPIN = True;     // Success
	return True;
}
else
{
	return False;
}

} //End Function
//END NPI check

function validate()
{

var err_msg = new Array();

var i=0;

var j=0;

var bigstring = "Please correct the following errors:\n";

var loginID = "";

var pass = "";

var count = 0;

var aMatch = false;

var aBlank = false;



firstName = document.addPhysician.fname.value;

lastName = document.addPhysician.lname.value;

homePhone = document.addPhysician.hphone.value;

mobilePhone = document.addPhysician.mphone.value;

zip = document.addPhysician.hzip.value;

userName = document.addPhysician.userName.value;

passWord = document.addPhysician.passWord.value;

confirmPassWord = document.addPhysician.confirmPassWord.value;

securityLevel = document.addPhysician.securityLevel.value;

email = document.addPhysician.email.value;

npi = document.addPhysician.npi.value;



if (trim(firstName).length < 1)

{

	 err_msg[i] = "First name cannot be blank.";

	 i++;

}

if (trim(lastName).length < 1)

{

	 err_msg[i] = "Last name cannot be blank.";

	 i++;

}



if (trim(homePhone).length < 1)

{

	 err_msg[i] = "Home phone cannot be blank.";

	 i++;

}

if (trim(homePhone).length >0)
{
   if(!(validatePH(homePhone)))
	{
		err_msg[i] = "Home Phone number must be 10 digits or in this format: NNN-NNN-NNNN.";
		i++;
	}
}


if (trim(mobilePhone).length < 1)

{

	 err_msg[i] = "Mobile phone cannot be blank.";

	 i++;

}

if (trim(zip).length > 0)
{
	if(!(validateZIP(zip)))
	{
		err_msg[i] = "Postal Code does not appear to be in the correct format NNNNN or NNNNN-NNNN.";
		i++;
	}
}

if (trim(npi).length < 1)

{

	 err_msg[i] = "NPI cannot be blank.";

	 i++;
	 alert("ALERT 1");

}


if ((trim(npi).length > 0) AND (trim(npi).length < 10))
{

	alert("here in length check");
	err_msg[i] = "Invalid NPI. Must be 10 digits.";

	i++;
}

if (is_numeric (trim(npi)) == False)
{
	alert("after length check");
	err_msg[i] = "Invalid NPI. Must be 10 digits.";

	i++;
}

if ((validateNPI(npi)) == "False")
{
	err_msg[i] = "NPI CDV check failed. Please re-enter.";
	i++;
}

 if (trim(userName).length<1)

 {

	   err_msg[i] = "Username cannot be blank.";

	   i++;

 }

 if (trim(passWord).length<1)

 {

	   err_msg[i] = "Password cannot be blank.";

	   i++;

	   aBlank = true;

 }



 if (trim(confirmPassWord).length<1)

 {

	   err_msg[i] = "Confirm password cannot be blank.";

	   i++;

	   aBlank = true;

 }



 if(!aBlank)

{

	if(passWord != confirmPassWord)

	{

		err_msg[i] = "The passwords do not match.";

		i++;

	}

	else

	{

		aMatch = true;

	}

}



if(aMatch)

{

	var theReg = /\d/g;


	if(!(passWord.match(theReg)) || (passWord.length < )
	{
		err_msg[i] = "The password must be at least 8 characters and contain at least one numeric character.";

		i++;

	}

}


 if ((securityLevel.length<1))

 {

	   err_msg[i] = "Select a security level.";

	   i++;

 }

 if (trim(email).length<1)

 {

	   err_msg[i] = "Enter an email address.";

	   i++;

 }

 if (i>0)

 {

	for (j=0; j<err_msg.length; j++) {

		count = j + 1;

		bigstring = bigstring + "\n" + count +". " + err_msg[j];

	}

	alert (bigstring);



	return false;

}

else

{

	return true;

}


}

 

in function validate, it works upto the point where i check for a blank npi field. but it fails when i try to check the lenght between 1 and 10 characters!! is something wrong here. it skips the rest of the checks once it gets to this point.

 

can u help me out here???

thanxxxxxx

  • 4 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.