[Javascript] How do you return more than one values from afunction ?
davecline at onebox.com
davecline at onebox.com
Tue Jul 6 11:39:34 CDT 2004
<html>
<head>
<script>
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function test(s){
var result = isValidEmail(s);
alert('Here is the result of your email test\n' +
result + '\n' +
'Now we\'ll pluck only the reason from the result object:\n' +
'Reason:' + result.reason
);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function isValidEmail(emailStr){
if (emailStr == 'good at email.com')
return {result:true,reason:''}
else
return {result:false,reason:'Your email is malformed.'}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Object.prototype.toString = function(){
var s = '';
for(var x in this){
if (x != 'undefined')
s += x + ":" + this[x] + "\n";
}
return s;
}
</script>
</head>
<body>
<button onclick="test('good at email.com')">Good email</button><br/>
<button onclick="test('bad at email.com')">Bad email</button><br/>
</body>
</html>
--
Dave Cline
davecline at gmail.com
www.bangeye.com/
801-636-5603
-----Original Message-----
From: Peter Brunone <peter at brunone.com>
Sent: Tue, 6 Jul 2004 08:35:28 -0700
To: <javascript at LaTech.edu>
Subject: re: [Javascript] How do you return more than one values from afunction ?
I would suggest either (a) altering a form field or global variable, or (b) returning an array of values.
Cheers,
Peter Brunone
_______________
EasyListBox.com
Original Message:
>From: <dev at qroute.net>
>Is byref allowed in JS ?
>
>function isValidEmail(emailStr, byref reason)
>{
> reason='abc'
> return false
> // is something like this possible
>}
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list