School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,331 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,806 people online right now. Registration is fast and FREE... Join Now!




Java Script Credit Card form creation with some additional requirement

 

Java Script Credit Card form creation with some additional requirement, with some additional requirements

mibit1

11 May, 2009 - 08:03 PM
Post #1

New D.I.C Head
*

Joined: 11 May, 2009
Posts: 2

Can somebody help me with HTML/Java Script source code for the Task below
IPB Image




Thank you all for helping me with this wink2.gif

User is offlineProfile CardPM
+Quote Post


Martyr2

RE: Java Script Credit Card Form Creation With Some Additional Requirement

11 May, 2009 - 08:07 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 7,243



Thanked: 820 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
It is site policy that we ask for a "best effort" attempt at solving the problem yourself first and then we can assist you. This means we do not provide code for you unless you show us what steps you have taken to do the work yourself. Show us what code you have written to actually try and solve the problem, we can then give you a push in the right direction.

smile.gif
User is offlineProfile CardPM
+Quote Post

mibit1

RE: Java Script Credit Card Form Creation With Some Additional Requirement

11 May, 2009 - 08:11 PM
Post #3

New D.I.C Head
*

Joined: 11 May, 2009
Posts: 2

so far I have only Credit Card validation

function onlydigits(str)
{
var re = new RegExp("([0-9]+)");
return (re.exec(str)!=null && RegExp.$1==str);
}

function checkccnumber(cardnum )
{

var cardnum = fld1.value;
if(cardnum.length > 0) cardnum = cardnum.replace(/ /gi,'');
if(cardnum.length > 0) cardnum = cardnum.replace(/-/gi,'');

if (cardnum.length<13 || cardnum.length>16)
{
alert("Credit card numbers must contain between 13 and 16 digits.");
return false;
}

if (!onlydigits(cardnum))
{
alert("Credit card numbers must contain only digits.");
return false;
}

var no_digit = cardnum.length;
var oddoeven = no_digit & 1;
var sum = 0;

for (var count = 0; count < no_digit; count++)
{
var digit = parseInt(cardnum.charAt(count),10);
if (!((count & 1) ^ oddoeven))
{
digit *= 2;
if (digit > 9)
digit -= 9;
}
sum += digit;
}
if (sum % 10 != 0)
{
alert("Credit card number is not valid. Please check that all digits were entered correctly.");
return false;
}

return true;
}


User is offlineProfile CardPM
+Quote Post

Martyr2

RE: Java Script Credit Card Form Creation With Some Additional Requirement

11 May, 2009 - 08:13 PM
Post #4

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 7,243



Thanked: 820 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
And what exactly are the problems you are having? Have you tried anything and it is not working? That is what I meant by showing us what you have "tried" but with no success.

This means you should have a question like "I am trying to do ______ but it is doing ______ and I don't understand why."
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 04:21PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month