rsammy Posted February 20, 2007 Share Posted February 20, 2007 i need help in validating a physicians NPI. anyone has any idea how to do this in php or javascript? this is my code in vb...! 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 Link to comment https://forums.phpfreaks.com/topic/39332-solved-npi-validation-in-php-urgent/ Share on other sites More sharing options...
rsammy Posted February 20, 2007 Author Share Posted February 20, 2007 more specifically, i need some help with this VB line here... totEven = CLng(Mid(txtPIN, 2, 1)) + CLng(Mid(txtPIN, 4, 1)) + CLng(Mid(txtPIN, 6, 1)) + CLng(Mid(txtPIN, 8, 1)) how do i code this one in javascript?! help with the whole function wud be great. but even this may help me a bit... THANX in advance Link to comment https://forums.phpfreaks.com/topic/39332-solved-npi-validation-in-php-urgent/#findComment-189690 Share on other sites More sharing options...
emehrkay Posted February 20, 2007 Share Posted February 20, 2007 you have to tell us what this does CLng(Mid(txtPIN, 2, 1)) and we'll tell you the php equivalent Link to comment https://forums.phpfreaks.com/topic/39332-solved-npi-validation-in-php-urgent/#findComment-189792 Share on other sites More sharing options...
rsammy Posted February 20, 2007 Author Share Posted February 20, 2007 never mind! i figured it out! thanx for ur reply Link to comment https://forums.phpfreaks.com/topic/39332-solved-npi-validation-in-php-urgent/#findComment-189822 Share on other sites More sharing options...
rsammy Posted February 20, 2007 Author Share Posted February 20, 2007 topic solved. i figured it out! Link to comment https://forums.phpfreaks.com/topic/39332-solved-npi-validation-in-php-urgent/#findComment-189824 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.