School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,131 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 3,938 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

#1 mibit1  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: New Members
  • Posts: 2
  • Joined: 11-May 09


Dream Kudos: 0

Posted 11 May 2009 - 08:03 PM

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




Thank you all for helping me with this ;)
Was This Post Helpful? 0
  • +
  • -


#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • Icon
  • View blog
  • Group: Mentors
  • Posts: 7,676
  • Joined: 18-April 07


Dream Kudos: 0

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

Posted 11 May 2009 - 08:07 PM

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.

:)
Was This Post Helpful? 0
  • +
  • -

#3 mibit1  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: New Members
  • Posts: 2
  • Joined: 11-May 09


Dream Kudos: 0

Posted 11 May 2009 - 08:11 PM

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;
}
Was This Post Helpful? 0
  • +
  • -

#4 Martyr2  Icon User is offline

  • Programming Theoretician
  • Icon
  • View blog
  • Group: Mentors
  • Posts: 7,676
  • Joined: 18-April 07


Dream Kudos: 0

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

Posted 11 May 2009 - 08:13 PM

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."
Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



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