473,497 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Merge to functions

How do I "merge" the two functions below - checkFromDate() and
checkToDate() - so that I only have one function. I want to do the same
validation in both text fields, but only have one function that does all
the validation.

<html>
<head>
<script language="JavaScript">
function checkFromDate() {
var ToFrom = document.form.txtFromDate.value
// Do some other validation...
}

function checkToDate() {
var ToDate = document.form.txtToDate.value
// Do same validation as above...
}
</script>
</head>
<body>
Start Date : <input type="text" name="txtFromDate"
onBlur="checkFromDate()"> yyyy/mm/dd <br>
End Date : <input type="text" name="txtToDate" onBlur="checkToDate()">
yyyy/mm/dd
</body>
</html>
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #1
3 1153
*** Andy wrote/escribió (15 Mar 2005 03:04:46 -0600):
How do I "merge" the two functions below - checkFromDate() and
checkToDate() - so that I only have one function. function checkFromDate() {
var ToFrom = document.form.txtFromDate.value
// Do some other validation...
}

function checkToDate() {
var ToDate = document.form.txtToDate.value
// Do same validation as above...
}


function checkDate() {
var ToFrom = document.form.txtFromDate.value
var ToDate = document.form.txtToDate.value
// Do some other validation...
}

--
-- Álvaro G. Vicario - Burgos, Spain
-- Don't e-mail me your questions, post them to the group
--
Jul 23 '05 #2
> How do I "merge" the two functions below - checkFromDate() and
checkToDate() - so that I only have one function. I want to do the same
validation in both text fields, but only have one function that does all
the validation. function checkFromDate() {
var ToFrom = document.form.txtFromDate.value
// Do some other validation...
}

function checkToDate() {
var ToDate = document.form.txtToDate.value
// Do same validation as above...
}


You can make a more generic function:

function checkDate(value) {
// Do some validation on value...
}

checkDate(document.form.txtFromDate.value);
checkDate(document.form.txtToDate.value);

That way you can reuse the function on other forms in other applications.

http://www.JSLint.com
Jul 23 '05 #3
Andy wrote:
[...]
function checkFromDate() {
var ToFrom = document.form.txtFromDate.value
// Do some other validation...
}


There is a good coverage of date validation here:

<URL:http://www.merlyn.demon.co.uk/js-date4.htm>
--
Rob
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3890
by: Sean Dettrick | last post by:
Hi, I have several <vector>'s of the same length, with entries as follows: I= A= B= I want to use STL to make (I == 0) a mask to operate on the elements of A and B, i.e. I want to do this:
8
5146
by: Darryl Kerkeslager | last post by:
I hope that although this is 25% Access and 75% Word, that someone will know ... The whole problem here arises because 1) Microsoft acknowledges an 'issue' wherein TextInput type FormFields are...
4
18611
by: marklawford | last post by:
Hi guys, I'm getting the following error message when trying to run a MERGE statement I'm putting together. The syntax looks right to me But i must be missing something. The "srce" table...
5
3522
by: uppe | last post by:
Hey everyone, I've just finished my implementation of the merge-sort algorithm in C, and I thought I could ask for some feedback. (One can always improve, they say) Right now, the code sorts...
1
2651
by: ckirby | last post by:
I've inherited an application for creating mail merges from an Access 2003 ADP that needs an overhaul. To generate the mail merge , the app uses a shell command: result = Shell(str, vbHide) ...
13
4004
by: ralphedge | last post by:
These sorts work fine on 100000 ints but if I go much higher they will both segmentation fault **************************MERGESORT********************* mergesort(int *a, int size) //a is...
0
967
by: raviee | last post by:
Hi Can anyone help me how to merge two database with all objects in sql server 2005. I have two database ie. a.MDF, b.MDF i want a new database c.mdf . simple merge only merge tables... i want...
9
9017
by: Aaron Watters | last post by:
....is to forget they are sorted??? While trying to optimize some NUCULAR libraries I discovered that the best way to merge 2 sorted lists together into a new sorted list is to just append them...
2
6020
by: Carmen Sei | last post by:
why the following code not compile ================ #include <iostream> using std::cout; // must need for using cout using std::endl; #include <string> using std::string;
0
7120
marktang
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,...
0
6991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6878
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...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
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...
0
1405
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
286
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.