|
 |
asp_databases thread: date validation
Message #1 by arshad siddiqui <ash_arshad@y...> on Wed, 7 Aug 2002 05:43:30 -0700 (PDT)
|
|
Hi,
I know this is not the correct place to ask this
question but still here goes my question.
I have a javascript that checks for date validation
but the problem is that I want to check for validation
only if I put something in that field otherwise it
should siply pass it off.but here if I leave the field
blank then it doesnot pass.
Please help.
I had tried many options but its not working.
Thanks
best regards
--Arshad--
The javascript that I am using:
<script>
function validRequired(formField,fieldLabel)
{
var result = true;
if (formField.value == "")
{
alert('Please enter a value for the "' +
fieldLabel +'" field.');
formField.focus();
result = false;
}
return result;
}
function validDate(formField,fieldLabel,required)
{
var result = true;
if (required &&
!validRequired(formField,fieldLabel))
result = false;
if (result)
{
var elems = formField.value.split("/");
result = (elems.length == 3); // should be three
components
if (result)
{
var month = parseInt(elems[0]);
var day = parseInt(elems[1]);
var year = parseInt(elems[2]);
result = !isNaN(month) && (month > 0) && (month
< 13) &&
!isNaN(day) && (day > 0) && (day < 32) &&
!isNaN(year) && (elems[2].length == 4);
}
if (!result)
{
alert('Please enter a date in the format
MM/DD/YYYY for the "' + fieldLabel +'" field.');
formField.focus();
}
}
return result;
}
function validate()
{
if (!validDate(fm.currentdate1,"currentdate",true)){
return false;
}
</script>
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
Message #2 by "Drew, Ron" <RDrew@B...> on Wed, 7 Aug 2002 09:56:18 -0400
|
|
Not sure what you are trying to do and what is your driver to execute
the script (onBlur, onSubmit)...
Do you want to check for a date to be entered..If entered validate else
just pass it along
..or..first tell the user it is required, set focus to it, then validate
after entered.
If you want the date to be mandatory, use a little popup calendar
javascript with gif to make sure you have a date.
http://javascript.internet.com/calendars/popup-date-picker.html
-----Original Message-----
From: arshad siddiqui [mailto:ash_arshad@y...]
Sent: Wednesday, August 07, 2002 8:44 AM
To: ASP Databases
Subject: [asp_databases] date validation
Hi,
I know this is not the correct place to ask this
question but still here goes my question.
I have a javascript that checks for date validation
but the problem is that I want to check for validation
only if I put something in that field otherwise it
should siply pass it off.but here if I leave the field
blank then it doesnot pass.
Please help.
I had tried many options but its not working.
Thanks
best regards
--Arshad--
The javascript that I am using:
<script>
function validRequired(formField,fieldLabel)
{
=A0=A0var result =3D true;
=A0=A0
=A0=A0if (formField.value =3D=3D "")
=A0=A0{
=A0=A0=A0=A0alert('Please enter a value for the "' +
fieldLabel +'" field.');
=A0=A0=A0=A0formField.focus();
=A0=A0=A0=A0result =3D false;
=A0=A0}
=A0=A0
=A0=A0return result;
}
function validDate(formField,fieldLabel,required)
{
var result =3D true;
if (required &&
!validRequired(formField,fieldLabel))
result =3D false;
if (result)
{
var elems =3D formField.value.split("/");
result =3D (elems.length =3D=3D 3); // should be three components
if (result)
{
var month =3D parseInt(elems[0]);
var day =3D parseInt(elems[1]);
var year =3D parseInt(elems[2]);
result =3D !isNaN(month) && (month > 0) && (month
< 13) &&
!isNaN(day) && (day > 0) && (day < 32) &&
!isNaN(year) && (elems[2].length =3D=3D 4);
}
if (!result)
{
alert('Please enter a date in the format
MM/DD/YYYY for the "' + fieldLabel +'" field.');
formField.focus();
}
}
return result;
}
function validate()
{
=A0=A0
=A0=A0if (!validDate(fm.currentdate1,"currentdate",true)){
=A0=A0
=A0=A0=A0=A0return false;
}
</script>
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better http://health.yahoo.com
Message #3 by "Chetan Kelkar" <chetan@c...> on Thu, 8 Aug 2002 09:08:38 +0530
|
|
not familiar much with javascript but in vb i would do something like
if textbox.value <> null then
-- do ur validation
else
continue
perhaps i might be able to write a code for u, i shall get back to u on this
after sometime
Chetan Kelkar
Software Developer,
chetan@c...
hotclaim25@h...
----- Original Message -----
From: "arshad siddiqui" <ash_arshad@y...>
To: "ASP Databases" <asp_databases@p...>
Sent: Wednesday, August 07, 2002 6:13 PM
Subject: [asp_databases] date validation
> Hi,
> I know this is not the correct place to ask this
> question but still here goes my question.
> I have a javascript that checks for date validation
> but the problem is that I want to check for validation
> only if I put something in that field otherwise it
> should siply pass it off.but here if I leave the field
> blank then it doesnot pass.
> Please help.
> I had tried many options but its not working.
> Thanks
> best regards
> --Arshad--
> The javascript that I am using:
>
> <script>
> function validRequired(formField,fieldLabel)
> {
> var result = true;
>
> if (formField.value == "")
> {
> alert('Please enter a value for the "' +
> fieldLabel +'" field.');
> formField.focus();
> result = false;
> }
>
> return result;
> }
>
>
> function validDate(formField,fieldLabel,required)
> {
> var result = true;
>
> if (required &&
> !validRequired(formField,fieldLabel))
> result = false;
>
> if (result)
> {
> var elems = formField.value.split("/");
>
> result = (elems.length == 3); // should be three
> components
>
> if (result)
> {
> var month = parseInt(elems[0]);
> var day = parseInt(elems[1]);
> var year = parseInt(elems[2]);
> result = !isNaN(month) && (month > 0) && (month
> < 13) &&
> !isNaN(day) && (day > 0) && (day < 32) &&
> !isNaN(year) && (elems[2].length == 4);
> }
>
> if (!result)
> {
> alert('Please enter a date in the format
> MM/DD/YYYY for the "' + fieldLabel +'" field.');
> formField.focus();
> }
> }
>
> return result;
> }
>
> function validate()
> {
>
>
> if (!validDate(fm.currentdate1,"currentdate",true)){
>
> return false;
> }
> </script>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - Feel better, live better
> http://health.yahoo.com
>
>
Message #4 by arshad siddiqui <ash_arshad@y...> on Sat, 10 Aug 2002 06:22:34 -0700 (PDT)
|
|
Hi,
I tried that but its not working.Please sujjest me
some other way to solve it either in javascript or
ASP.
Thanks
Regards
--Arshad--
--- Chetan Kelkar <chetan@c...> wrote:
> not familiar much with javascript but in vb i would
> do something like
>
> if textbox.value <> null then
> -- do ur validation
>
> else
> continue
>
> perhaps i might be able to write a code for u, i
> shall get back to u on this
> after sometime
> Chetan Kelkar
> Software Developer,
> chetan@c...
> hotclaim25@h...
>
> ----- Original Message -----
> From: "arshad siddiqui" <ash_arshad@y...>
> To: "ASP Databases" <asp_databases@p...>
> Sent: Wednesday, August 07, 2002 6:13 PM
> Subject: [asp_databases] date validation
>
>
> > Hi,
> > I know this is not the correct place to ask this
> > question but still here goes my question.
> > I have a javascript that checks for date
> validation
> > but the problem is that I want to check for
> validation
> > only if I put something in that field otherwise it
> > should siply pass it off.but here if I leave the
> field
> > blank then it doesnot pass.
> > Please help.
> > I had tried many options but its not working.
> > Thanks
> > best regards
> > --Arshad--
> > The javascript that I am using:
> >
> > <script>
> > function validRequired(formField,fieldLabel)
> > {
> > var result = true;
> >
> > if (formField.value == "")
> > {
> > alert('Please enter a value for the "' +
> > fieldLabel +'" field.');
> > formField.focus();
> > result = false;
> > }
> >
> > return result;
> > }
> >
> >
> > function validDate(formField,fieldLabel,required)
> > {
> > var result = true;
> >
> > if (required &&
> > !validRequired(formField,fieldLabel))
> > result = false;
> >
> > if (result)
> > {
> > var elems = formField.value.split("/");
> >
> > result = (elems.length == 3); // should be
> three
> > components
> >
> > if (result)
> > {
> > var month = parseInt(elems[0]);
> > var day = parseInt(elems[1]);
> > var year = parseInt(elems[2]);
> > result = !isNaN(month) && (month > 0) &&
> (month
> > < 13) &&
> > !isNaN(day) && (day > 0) && (day < 32)
> &&
> > !isNaN(year) && (elems[2].length ==
> 4);
> > }
> >
> > if (!result)
> > {
> > alert('Please enter a date in the format
> > MM/DD/YYYY for the "' + fieldLabel +'" field.');
> > formField.focus();
> > }
> > }
> >
> > return result;
> > }
> >
> > function validate()
> > {
> >
> >
> > if
> (!validDate(fm.currentdate1,"currentdate",true)){
> >
> > return false;
> > }
> > </script>
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Health - Feel better, live better
> > http://health.yahoo.com
> >
> >
>
>
__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com
Message #5 by "Kim Iwan Hansen" <kimiwan@k...> on Sat, 10 Aug 2002 17:01:05 +0200
|
|
In ASP, use IsDate()
if IsDate(var) then
'it's a date
else
'it's not a date
end if
-Kim
> -----Original Message-----
> From: arshad siddiqui [mailto:ash_arshad@y...]
> Sent: 10. august 2002 15:23
> To: ASP Databases
> Subject: [asp_databases] Re: date validation
>
>
> Hi,
> I tried that but its not working.Please sujjest me
> some other way to solve it either in javascript or
> ASP.
> Thanks
> Regards
> --Arshad--
>
>
>
> --- Chetan Kelkar <chetan@c...> wrote:
> > not familiar much with javascript but in vb i would
> > do something like
> >
> > if textbox.value <> null then
> > -- do ur validation
> >
> > else
> > continue
> >
> > perhaps i might be able to write a code for u, i
> > shall get back to u on this
> > after sometime
> > Chetan Kelkar
> > Software Developer,
> > chetan@c...
> > hotclaim25@h...
> >
> > ----- Original Message -----
> > From: "arshad siddiqui" <ash_arshad@y...>
> > To: "ASP Databases" <asp_databases@p...>
> > Sent: Wednesday, August 07, 2002 6:13 PM
> > Subject: [asp_databases] date validation
> >
> >
> > > Hi,
> > > I know this is not the correct place to ask this
> > > question but still here goes my question.
> > > I have a javascript that checks for date
> > validation
> > > but the problem is that I want to check for
> > validation
> > > only if I put something in that field otherwise it
> > > should siply pass it off.but here if I leave the
> > field
> > > blank then it doesnot pass.
> > > Please help.
> > > I had tried many options but its not working.
> > > Thanks
> > > best regards
> > > --Arshad--
> > > The javascript that I am using:
> > >
> > > <script>
> > > function validRequired(formField,fieldLabel)
> > > {
> > > var result = true;
> > >
> > > if (formField.value == "")
> > > {
> > > alert('Please enter a value for the "' +
> > > fieldLabel +'" field.');
> > > formField.focus();
> > > result = false;
> > > }
> > >
> > > return result;
> > > }
> > >
> > >
> > > function validDate(formField,fieldLabel,required)
> > > {
> > > var result = true;
> > >
> > > if (required &&
> > > !validRequired(formField,fieldLabel))
> > > result = false;
> > >
> > > if (result)
> > > {
> > > var elems = formField.value.split("/");
> > >
> > > result = (elems.length == 3); // should be
> > three
> > > components
> > >
> > > if (result)
> > > {
> > > var month = parseInt(elems[0]);
> > > var day = parseInt(elems[1]);
> > > var year = parseInt(elems[2]);
> > > result = !isNaN(month) && (month > 0) &&
> > (month
> > > < 13) &&
> > > !isNaN(day) && (day > 0) && (day < 32)
> > &&
> > > !isNaN(year) && (elems[2].length ==
> > 4);
> > > }
> > >
> > > if (!result)
> > > {
> > > alert('Please enter a date in the format
> > > MM/DD/YYYY for the "' + fieldLabel +'" field.');
> > > formField.focus();
> > > }
> > > }
> > >
> > > return result;
> > > }
> > >
> > > function validate()
> > > {
> > >
> > >
> > > if
> > (!validDate(fm.currentdate1,"currentdate",true)){
> > >
> > > return false;
> > > }
> > > </script>
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Health - Feel better, live better
> > > http://health.yahoo.com
> > >
> > >
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> HotJobs - Search Thousands of New Jobs
> http://www.hotjobs.com
>
Message #6 by "Gavin Landon" <glandon@g...> on Mon, 12 Aug 2002 15:52:05 -0500
|
|
http://www.smartwebby.com/DHTML/date_validation.asp
"arshad siddiqui" <ash_arshad@y...> wrote in message
news:203327@a..._databases...
>
> Hi,
> I tried that but its not working.Please sujjest me
> some other way to solve it either in javascript or
> ASP.
> Thanks
> Regards
> --Arshad--
>
>
>
> --- Chetan Kelkar <chetan@c...> wrote:
> > not familiar much with javascript but in vb i would
> > do something like
> >
> > if textbox.value <> null then
> > -- do ur validation
> >
> > else
> > continue
> >
> > perhaps i might be able to write a code for u, i
> > shall get back to u on this
> > after sometime
> > Chetan Kelkar
> > Software Developer,
> > chetan@c...
> > hotclaim25@h...
> >
> > ----- Original Message -----
> > From: "arshad siddiqui" <ash_arshad@y...>
> > To: "ASP Databases" <asp_databases@p...>
> > Sent: Wednesday, August 07, 2002 6:13 PM
> > Subject: [asp_databases] date validation
> >
> >
> > > Hi,
> > > I know this is not the correct place to ask this
> > > question but still here goes my question.
> > > I have a javascript that checks for date
> > validation
> > > but the problem is that I want to check for
> > validation
> > > only if I put something in that field otherwise it
> > > should siply pass it off.but here if I leave the
> > field
> > > blank then it doesnot pass.
> > > Please help.
> > > I had tried many options but its not working.
> > > Thanks
> > > best regards
> > > --Arshad--
> > > The javascript that I am using:
> > >
> > > <script>
> > > function validRequired(formField,fieldLabel)
> > > {
> > > var result = true;
> > >
> > > if (formField.value == "")
> > > {
> > > alert('Please enter a value for the "' +
> > > fieldLabel +'" field.');
> > > formField.focus();
> > > result = false;
> > > }
> > >
> > > return result;
> > > }
> > >
> > >
> > > function validDate(formField,fieldLabel,required)
> > > {
> > > var result = true;
> > >
> > > if (required &&
> > > !validRequired(formField,fieldLabel))
> > > result = false;
> > >
> > > if (result)
> > > {
> > > var elems = formField.value.split("/");
> > >
> > > result = (elems.length == 3); // should be
> > three
> > > components
> > >
> > > if (result)
> > > {
> > > var month = parseInt(elems[0]);
> > > var day = parseInt(elems[1]);
> > > var year = parseInt(elems[2]);
> > > result = !isNaN(month) && (month > 0) &&
> > (month
> > > < 13) &&
> > > !isNaN(day) && (day > 0) && (day < 32)
> > &&
> > > !isNaN(year) && (elems[2].length ==
> > 4);
> > > }
> > >
> > > if (!result)
> > > {
> > > alert('Please enter a date in the format
> > > MM/DD/YYYY for the "' + fieldLabel +'" field.');
> > > formField.focus();
> > > }
> > > }
> > >
> > > return result;
> > > }
> > >
> > > function validate()
> > > {
> > >
> > >
> > > if
> > (!validDate(fm.currentdate1,"currentdate",true)){
> > >
> > > return false;
> > > }
> > > </script>
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Health - Feel better, live better
> > > http://health.yahoo.com
> > >
> > >
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> HotJobs - Search Thousands of New Jobs
> http://www.hotjobs.com
>
>
|
|
 |