/    Sign up×
Community /Pin to ProfileBookmark

credit card validation

Hi,

im trying to setup validation for a customers cc details. how would i do this to the following textfields?

<td width=”65%”> <select name=”C_CcType” id=”C_CcType”>
<option selected>Visa</option>
<option>MasterCard</option>
<option>American Express</option>
</select> </td>
</tr>
<tr>
<td width=”35%”><font color=”#FFFFFF” face=”Times New Roman, Times, serif”>Card
Number</font></td>
<td width=”65%”> <input type=”text” name=”C_CcNum” class=”textBoxNormal” onfocus=”this.className=’textBoxActive'” onblur=”this.className=’textBoxNormal'”>
</td>
</tr>
<tr>
<td width=”35%”><font color=”#FFFFFF” face=”Times New Roman, Times, serif”>Expiry
Date</font></td>
<td width=”65%”> <input type=”text” name=”C_ExpD” class=”textBoxNormal” onfocus=”this.className=’textBoxActive'” onblur=”this.className=’textBoxNormal'”> </td>
</tr>
<tr>
<td width=”35%”><font color=”#FFFFFF” face=”Times New Roman, Times, serif”>Sec
Code </font></td>
<td width=”65%”> <input type=”text” name=”C_Sec” class=”textBoxNormal” onfocus=”this.className=’textBoxActive'” onblur=”this.className=’textBoxNormal'”> </td>
</tr>
<tr>
<td colspan=”2″>&nbsp; </td>
</tr>
</table>

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@BeachSideFeb 19.2005 — Are you trying to do this client side or server side? If client side you would be better off with JavaScript (not a very good idea though) or you can do it server side with php and a regex that validates that at least it is a possible valid cc# that was entered.

Something like...

'/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{14}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/',$
Copy linkTweet thisAlerts:
@pyroFeb 19.2005 — Do a google search for LUHN/Mod 10 algorithm... that's a start.
×

Success!

Help @clonmelog spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...