...

View Full Version : Form Validation



verdeh
08-20-2004, 10:33 PM
I have never used JavaScript before. Is it possible to check to see if another box on the form has any entry in it before making it mandatory to fill out the rest of the form? Like if the person enters an item, then they would have to fill out the description box on the form, but only if there was an entry made in the item box. I know that you can check to make sure that a box is filled in, but I want to tie two boxes together.

Basscyst
08-21-2004, 12:32 AM
Quite possible. . . .

Somthing like this?



<html>
<head>
<style type="text/css">
.opt
{
background-color:#c2c2c2;
}
</style>
<script type="text/javascript">

function writeFields()
{
var f1=document.getElementById('field1');
var f2=document.getElementById('field2');
var f3=document.getElementById('field3');
if(f1.value!="")
{
f2.onfocus="";
f3.onfocus="";
f2.style.background="#FFF";
f3.style.background="#FFF";
}
}
</script>
</head>
<body>
<form>
<input type="text" onblur="writeFields()" id="field1">
<input type="text" class="opt" onfocus="this.blur();" id="field2">
<input type="text" class="opt" onfocus="this.blur();"id="field3">
</body>
</html>


Basscyst



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum