Validate a field

  • Thread starter Thread starter SS
  • Start date Start date
S

SS

Hi

I know how to validate a field but what I would like to do is if one field
is filled in then make sure the next 4 fields are filled in.

Is this possible?

Thanks Shona
 
Only w/ custom JavaScript (and then you could not use FP validation)

--




| Hi
|
| I know how to validate a field but what I would like to do is if one field
| is filled in then make sure the next 4 fields are filled in.
|
| Is this possible?
|
| Thanks Shona
|
|
 
Hi,
you'd need something like this
<script type="text/javascript">
function checkIt(f){
var ok = true;
if(f.one.value){
for(i=1;i<5;i++){
if(!f.elements.value){ok=false;alert('Error Message');break}}}
return ok;
}
</script>
<form onsubmit="return checkIt(this);">
This is the one field <input type="text" name="one">
these are the 4 that need to be filled in
<input type="text" name="two">
<input type="text" name="three">
<input type="text" name="four">
<input type="text" name="five">

Post back if you need to tie this in with the FP validation
 
Hi

Thanks that's great got that to work on it's own but yes I have a large form
and some of the fields are validated and others are not.

I actually need this over 6 areas all with if the first box is filled in the
next 4 fields need to be filled.

I thought maybe I only needed to copy the script down eg

function checkIt(f){
var ok = true;
if(f.driveletter1.value){
for(i=1;i<6;i++){
if(!f.elements.value){ok=false;alert('Please fill in the next
field');break}}}
return ok;
}


function checkIt(f){
var ok = true;
if(f.driveletter2.value){
for(i=1;i<6;i++){
if(!f.elements.value){ok=false;alert('Please fill in the next
field');break}}}
return ok;
}

But that didn't seem to work!

Any ideas would be great Thanks
Shona
 
Back
Top