PDA

View Full Version : problem with verification script :p


vkidv
10-10-2002, 08:05 PM
okay, im having problems with this script ive made;
and im sure ive missed somthing really improtant out :(

<html>
<script>
function dothat() {
var rec=document.me.recipient.value;
var item=document.me2.item2.value;
var trick1=""+rec+" has giving you "+item+".";
var trick2=""+rec+" has giving you "+item+".";
var item=document.me2.item2.value;
if ((rec==null) && (item==null))
{
alert("please type data in all fields");
}
else
alert("now submitting")
}
</script>
<form name="me">
<input type='text' name='recipient' size=12 maxlength=20>
<input type='hidden' name='message_body'>
</form>
<form name="me2">
<input type='text' name='item2' size=12 maxlength=20>
<input type="button" name="B1" value="Submit" onclick="dothat()">
</form>
</html>

adios
10-10-2002, 08:28 PM
Can't say I follow what you're doing - but, anyway, your validator:

if ((rec==null) && (item==null))

The JS null value is a specific type, and you won't find it here (in a empty form field) - what you're testing for is the null (empty) string:

if ((rec=='') || (item==''))

Notice the use of the OR operator, evaluating to true if either field is empty. Save yourself some typing:

if (!rec || !item)

hth, adios

glenngv
10-11-2002, 04:17 AM
and this:

var rec=document.me.recipient.value;
var item=document.me2.item2.value;
var trick1=""+rec+" has giving you "+item+".";
var trick2=""+rec+" has giving you "+item+".";
var item=document.me2.item2.value;

should only be:

var rec=document.me.recipient.value;
var item=document.me2.item2.value;
var trick1=rec+" has giving you "+item+".";
var trick2=rec+" has giving you "+item+".";

but i don't see you use trick1 and trick2 anywhere.

vkidv
10-11-2002, 04:08 PM
hey thankyou all!

:)