Script Categories













Forms >>> Only One Field.

The visitor must fill in either one of two fields, their name or email address. If they click in either box the other box's value is erased. Ensures that when the form is submitted only one field contains a value. Also contains validation that makes sure both fields are not empty.

Please enter your name or your email address.

Name Email
Or...

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function checkFields() {
name = document.submitform.name.value;
email = document.submitform.email.value;

if ((name == "") && (email == "") ) {
alert("Please enter your name or your email address.");
return false;
}
else return true;
}
//  End -->
</script>
<form action="http://www.your-web-site-address-here.com/script.cgi" name=submitform onSubmit="return checkFields()">

Please enter your name or your email address.<br><br>
<table border=0>
<tr>
<td
align=center>Name</td>
<td>
</td>
<td
align=center>Email</td>
</tr>
<tr>
<td
align=center><input type=text name=name value="" onFocus="document.submitform.email.value='';" size=10></td>
<td
align=center>Or...</td>
<td
align=center><input type=text name=email value="" onFocus="document.submitform.name.value='';" size=10></td>
</tr>
<tr>
<td
colspan=3 align=center><input type=submit value="Submit!"></td>
</tr>
</table>
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©