Hi,
I need to write a Javascript which calculates datedifference as well
as date comparision.Whe n i try to embed the below script,it is working
well,but the page is submitting even when the condition evaluates to
false .Please let me know the reason what is the problem in the below
script.
function ValidateDate()
{
var fromDate=new
Date(document.g etElementById(" txtFromFiledDat e").value);
var toDate=new
Date(document.g etElementById(" txtToFiledDate" ).value);
var diffDate=new Date();
diffDate = (toDate - fromDate);
diffDate = ((((diffDate / 1000) / 60) / 60) / 24);
alert("Differen ce is: " + diffDate);
alert(diffDate> 30);
if(diffDate<0){ alert("Start Date cannot be after End Date!")
return false;}
if(diffDate>30 && diffDate<0) {alert("Please enter the date in
Range")
return false;}
return true;
}
Thanks,
Vishnu 22 2254 se****@gmail.co m wrote:
>
Hi,
I need to write a Javascript which calculates datedifference as well
as date comparision.Whe n i try to embed the below script,it is working
well,but the page is submitting even when the condition evaluates to
false .Please let me know the reason what is the problem in the below
script.
function ValidateDate()
{
var fromDate=new
Date(document.g etElementById(" txtFromFiledDat e").value);
var toDate=new
Date(document.g etElementById(" txtToFiledDate" ).value);
var diffDate=new Date();
diffDate = (toDate - fromDate);
diffDate = ((((diffDate / 1000) / 60) / 60) / 24);
alert("Differen ce is: " + diffDate);
alert(diffDate> 30);
if(diffDate<0){ alert("Start Date cannot be after End Date!")
return false;}
if(diffDate>30 && diffDate<0) {alert("Please enter the date in
Range")
return false;}
return true;
}
Thanks,
Vishnu
Hi,
How does your formtag look?
It should look like this:
<form action="bla" onSubmit="retur n ValidateDate(); ">
mind the return before the functioncall.
If onSubmit returns false, the form is not submitted.
A common mistake is to forget the return (speaking from own experience.)
Regards,
Erwin Moller
Hi Erwin,
Thanks for your lightening response.As you said,i forgot to specify
return statement while calling the function.
Thanks,
Vishnu
Erwin Moller wrote:
se****@gmail.co m wrote:
Hi,
I need to write a Javascript which calculates datedifference as well
as date comparision.Whe n i try to embed the below script,it is working
well,but the page is submitting even when the condition evaluates to
false .Please let me know the reason what is the problem in the below
script.
function ValidateDate()
{
var fromDate=new
Date(document.g etElementById(" txtFromFiledDat e").value);
var toDate=new
Date(document.g etElementById(" txtToFiledDate" ).value);
var diffDate=new Date();
diffDate = (toDate - fromDate);
diffDate = ((((diffDate / 1000) / 60) / 60) / 24);
alert("Differen ce is: " + diffDate);
alert(diffDate> 30);
if(diffDate<0){ alert("Start Date cannot be after End Date!")
return false;}
if(diffDate>30 && diffDate<0) {alert("Please enter the date in
Range")
return false;}
return true;
}
Thanks,
Vishnu
Hi,
How does your formtag look?
It should look like this:
<form action="bla" onSubmit="retur n ValidateDate(); ">
mind the return before the functioncall.
If onSubmit returns false, the form is not submitted.
A common mistake is to forget the return (speaking from own experience.)
Regards,
Erwin Moller
Hi,
Now am facing another issue.It is telling script error "return
statement outside the function"
Please let me know why am getting this error.
Thanks,
Vishnu se****@gmail.co m wrote:
Hi Erwin,
Thanks for your lightening response.As you said,i forgot to specify
return statement while calling the function.
Thanks,
Vishnu
Erwin Moller wrote:
se****@gmail.co m wrote:
>
Hi,
>
I need to write a Javascript which calculates datedifference as well
as date comparision.Whe n i try to embed the below script,it is working
well,but the page is submitting even when the condition evaluates to
false .Please let me know the reason what is the problem in the below
script.
>
>
function ValidateDate()
{
>
var fromDate=new
Date(document.g etElementById(" txtFromFiledDat e").value);
var toDate=new
Date(document.g etElementById(" txtToFiledDate" ).value);
var diffDate=new Date();
diffDate = (toDate - fromDate);
diffDate = ((((diffDate / 1000) / 60) / 60) / 24);
alert("Differen ce is: " + diffDate);
alert(diffDate> 30);
if(diffDate<0){ alert("Start Date cannot be after End Date!")
return false;}
if(diffDate>30 && diffDate<0) {alert("Please enter the date in
Range")
return false;}
return true;
}
>
>
Thanks,
Vishnu
Hi,
How does your formtag look?
It should look like this:
<form action="bla" onSubmit="retur n ValidateDate(); ">
mind the return before the functioncall.
If onSubmit returns false, the form is not submitted.
A common mistake is to forget the return (speaking from own experience.)
Regards,
Erwin Moller
wrote on 26 okt 2006 in comp.lang.javas cript:
I need to write a Javascript
"need" = school work? Let's hope not!
which calculates datedifference as well
as date comparision.Whe n i try to embed the below script,it is working
well,but the page is submitting
submitting?
You do not show the code.
even when the condition evaluates to
false .Please let me know the reason what is the problem in the below
script.
function ValidateDate()
{
[..]
if(diffDate>30 && diffDate<0)
A value can NEVER be both more than 30 and less than zero ;-{
[..]
Do not read on, if this is a school assignment,
you will never learn, if you do not try to program for yourself.
=============== =============== =============== ===
<script type='text/javascript'>
function ValidateDate( f ) {
var d1 = new Date( f.elements['fromDate'].value );
var d2 = new Date( f.elements['toDate'].value );
// below formula from John Stockton at
// <http://www.merlyn.demo n.co.uk/js-date1.htm#DDf>
// no account is taken of summer/winter and other time differences.
var diffDate = Math.round( ( d2-d1 ) / 864e5 );
// alert( diffDate ); // debugger
if ( diffDate < 0 ) {
alert( 'The start date cannot be after the end date!")
return false;
}
if ( diffDate 30 ) {
alert( 'Please enter dates less than 31 days apart' )
return false;
}
return true; // allow submit
}
</script>
<form onsubmit='retur n ValidateDate( this );'>
<input name='fromDate' value='2006/1/1'start<br>
<input name='toDate' value='2006/12/1'end<br>
<input type='submit'>
</form>
=============== =============== =============== ====
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Hi,
function ValidateDate()
{
var fromDate=new
Date(document.g etElementById(" txtFromFiledDat e").value);
var toDate=new
Date(document.g etElementById(" txtToFiledDate" ).value);
var diffDate = Math.round( ( toDate-fromDate ) / 864e5 );
if ( diffDate < 0 ) {
alert( "The start date cannot be after the end date!")
return false;
}
if ( diffDate 30 ) {
alert( "Please enter dates less than 31 days apart" )
return false;
}
return true;
}
I am trying to use this javascript for client-side validation in my
ASPX page using customvalidator control as below:
<asp:CustomVali dator id="CustomValid ator1" runat="server"
ClientValidatio nFunction="retu rn
ValidateDate(); "></asp:CustomValid ator>
Now the problem with the function is that the page is submitting when
datediff<0 .it should not submit.Also alert msg is coming twice and
submitting the page.
Please let me know what is the reason for this.
Thanks,
Vishnu
i have a search button on my screen.When i enter the dates and click it
has to validate.
Matt Kruse wrote:
se****@gmail.co m wrote:
I need to write a Javascript which calculates datedifference as well
as date comparision.
Is this for a homework assignment or something?
If not, why not just use a lib which already does a lot of the work for you: http://www.javascripttoolbox.com/lib/date/
--
Matt Kruse http://www.JavascriptToolbox.com http://www.AjaxToolbox.com
Hi,
How do i write the same function with parameters? Please help me.
Thanks,
Vishnu
Evertjan. wrote:
wrote on 26 okt 2006 in comp.lang.javas cript:
I need to write a Javascript
"need" = school work? Let's hope not!
which calculates datedifference as well
as date comparision.Whe n i try to embed the below script,it is working
well,but the page is submitting
submitting?
You do not show the code.
even when the condition evaluates to
false .Please let me know the reason what is the problem in the below
script.
function ValidateDate()
{
[..]
if(diffDate>30 && diffDate<0)
A value can NEVER be both more than 30 and less than zero ;-{
[..]
Do not read on, if this is a school assignment,
you will never learn, if you do not try to program for yourself.
=============== =============== =============== ===
<script type='text/javascript'>
function ValidateDate( f ) {
var d1 = new Date( f.elements['fromDate'].value );
var d2 = new Date( f.elements['toDate'].value );
// below formula from John Stockton at
// <http://www.merlyn.demo n.co.uk/js-date1.htm#DDf>
// no account is taken of summer/winter and other time differences.
var diffDate = Math.round( ( d2-d1 ) / 864e5 );
// alert( diffDate ); // debugger
if ( diffDate < 0 ) {
alert( 'The start date cannot be after the end date!")
return false;
}
if ( diffDate 30 ) {
alert( 'Please enter dates less than 31 days apart' )
return false;
}
return true; // allow submit
}
</script>
<form onsubmit='retur n ValidateDate( this );'>
<input name='fromDate' value='2006/1/1'start<br>
<input name='toDate' value='2006/12/1'end<br>
<input type='submit'>
</form>
=============== =============== =============== ====
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Hi,
How do i write the same function with parameters? Please help me.
Thanks,
Vishnu
Evertjan. wrote:
wrote on 26 okt 2006 in comp.lang.javas cript:
I need to write a Javascript
"need" = school work? Let's hope not!
which calculates datedifference as well
as date comparision.Whe n i try to embed the below script,it is working
well,but the page is submitting
submitting?
You do not show the code.
even when the condition evaluates to
false .Please let me know the reason what is the problem in the below
script.
function ValidateDate()
{
[..]
if(diffDate>30 && diffDate<0)
A value can NEVER be both more than 30 and less than zero ;-{
[..]
Do not read on, if this is a school assignment,
you will never learn, if you do not try to program for yourself.
=============== =============== =============== ===
<script type='text/javascript'>
function ValidateDate( f ) {
var d1 = new Date( f.elements['fromDate'].value );
var d2 = new Date( f.elements['toDate'].value );
// below formula from John Stockton at
// <http://www.merlyn.demo n.co.uk/js-date1.htm#DDf>
// no account is taken of summer/winter and other time differences.
var diffDate = Math.round( ( d2-d1 ) / 864e5 );
// alert( diffDate ); // debugger
if ( diffDate < 0 ) {
alert( 'The start date cannot be after the end date!")
return false;
}
if ( diffDate 30 ) {
alert( 'Please enter dates less than 31 days apart' )
return false;
}
return true; // allow submit
}
</script>
<form onsubmit='retur n ValidateDate( this );'>
<input name='fromDate' value='2006/1/1'start<br>
<input name='toDate' value='2006/12/1'end<br>
<input type='submit'>
</form>
=============== =============== =============== ====
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
wrote on 26 okt 2006 in comp.lang.javas cript:
>> ============== =============== =============== ==== <script type='text/javascript'>
function ValidateDate( f ) {
var d1 = new Date( f.elements['fromDate'].value ); var d2 = new Date( f.elements['toDate'].value );
// below formula from John Stockton at // <http://www.merlyn.demo n.co.uk/js-date1.htm#DDf> // no account is taken of summer/winter and other time differences.
var diffDate = Math.round( ( d2-d1 ) / 864e5 );
// alert( diffDate ); // debugger
if ( diffDate < 0 ) { alert( 'The start date cannot be after the end date!") return false; }
if ( diffDate 30 ) { alert( 'Please enter dates less than 31 days apart' ) return false; }
return true; // allow submit }
</script>
<form onsubmit='retur n ValidateDate( this );'> <input name='fromDate' value='2006/1/1'start<br> <input name='toDate' value='2006/12/1'end<br> <input type='submit'> </form> ============== =============== =============== =====
[Please do not toppost on usenet, use sparse interquote]
How do i write the same function with parameters? Please help me.
Is the (f) not parameter enough?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lodewijk van Haringhal |
last post by:
I'am new with javascritping not with programming. Is there nobody who can
help me with ths simple promblem? :) Please, please give me a hint.
Please help me with this script. I have two lists in my form. One to choose
a directory and one to choose a picture. The script bellow works perfect
without the directory choose function.
I tried to make the directory choose function myself but I did not succeed.
I think I made a mistake here:...
|
by: dave |
last post by:
Hi guys
I display one page in popup window...that fetches some data from sql and
perfom some calculation (tht approx 10 secs) and display result....
I am trying to display "Please wait ..."message while its performing
calculation...
I'm using the below code...that i have got from following link
http://aspfaq.com/show.asp?id=2498
but somehow it doesnt work and displays nothing....it display only for a
second before the actual result is...
|
by: John Dalberg |
last post by:
Hi
I have a form that opens a new window for the results. Because the results
might take a few seconds due to server processing, I would like to display
a message "please wait" in the new window, erase that message when the
processing is done and show the results.
How is this done?
John Dalberg
|
by: rked |
last post by:
I get nameSPAN1 is undefined when I place cursor in comments box..
<%@ LANGUAGE="VBScript" %>
<% DIM ipAddress
ipAddress=Request.Servervariables("REMOTE_HOST")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
|
by: milkyway |
last post by:
Hello,
I have an HTML page that I am trying to import 2 .js file (I created)
into. These files are: row_functions.js and data_check_functions.js.
Whenever I bring the contents of the files into this HTML file, all is
OK but whenever the functions are separated (as it is now), when I run
the page, I get the following error:
Line 73, object expected.
| |
by: joe kenney |
last post by:
I have a question on designing a please wait aspx page.
Currently I have a test.aspx page with codebehind page and
page_onload contains my stored procedure calls. I've
create something similar in old asp so I've try similiar
method and I sort of got it work however my please wait
message gets display the same time as my data so is there
a way to display what's in my <div> tag first, then
executed page_onload for my stored procedure...
|
by: Aws |
last post by:
My crazy GridView !!
I am using Visual Studio 2005, I have a problem with my GridView.
I have one access .mdb table and when I update a record on the table
EVERYTHING is perfect. I made a Web Setup Project and installed My Web
Application on my Localhost and it works perfectly.
When I install My Web Application on our “Production Server” it just doesn’t
update the records on Edit mode!!!
|
by: bigpoppa |
last post by:
Hey I need help (doesn't everyone?) on a script. The script functions like this:
Please wait X seconds for download (for example x=15 seconds)
Please wait 14 seconds for download (and then a second later)
Please wait 13 seconds for download... (process keeps repeating)
Click here to download the file you requested (occurs at 0 seconds)
Does anyone know of a script like that one? I have seen many sites use it including megaupload.com. I am...
|
by: adamalton |
last post by:
Hi, I'm building a site where the user enters some info into a form which submits to a php script. The php script takes a long time to execute (anywhere from 10 seconds to a minute) and when it finally finishes the page that it creates appears to get blocked by any firewall (tried on lots of different browsers/platforms) and you just get a completely blank page. (It's fine when just running on my local machine.)
I'm guessing that the script...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |