...

View Full Version : Need Help on this script



Rudurk
07-16-2006, 02:25 PM
right mm i am kind of stuck on this bit am just learning html


if (document.form1.vdfmm.value < 1&&document.form1.vdfmm.value > 12)
{
dAlert();
}

this works fyn but if i use


if (document.form1.vdfmm.value < 01&&document.form1.vdfmm.value > 12)
{
dAlert();
}

the 01 doesnt seem to be counting how do i make it so it can recognise 01,02,03,04,05,06,07,08,09,10,11,12

the 0 messes it up

this is script is for a credit card validator if it helps you understand it better

Rudurk
07-16-2006, 03:43 PM
Can i please also know how can i validate a email address

sage45
07-16-2006, 06:44 PM
This really should have been posted in the javascript area... I will move it there, however I will answer your question... The reason is that from a submission standpoint the leading 0 is stripped off as it is not needed...

-saige-

Rudurk
07-16-2006, 06:57 PM
so how can i make it so it will count 01? any ideas?

Philip M
07-17-2006, 07:10 AM
You need to convert the value to a number.

var mnth = parseInt (document.form1.vdfmm.value);
if (mnth < 1 || mnth > 12) {
dAlert();
}

The number cannot be both smaller than 1 and greater than 12.

As for your question about validating an email address, I suggest you try Google
or use the search feature of this forum.

vwphillips
07-17-2006, 08:48 AM
if (document.form1.vdfmm.value < 01&&document.form1.vdfmm.value > 12&&document.form1.vdfmm.value.length!=2)
{
dAlert();
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum