PDA

View Full Version : Resolved & won't validate



mcolton
08-23-2009, 11:17 AM
I have some field checking on forms that works great but it won't validate in xhtml strict. I get errors about the "&"
What's the trick around this. I tried "&&" and that didn't work.

Below is partial code:



<script type="text/javascript">
function validate() {
mNv10=dogadoptionform.own.value;
mNv11=dogadoptionform.permission.value;

if (!(dogadoptionform.own[0].checked || dogadoptionform.own[1].checked)) {
alert('Own/Rent is a required question.');
event.returnValue=false;
}

if ((!(dogadoptionform.permission[0].checked || dogadoptionform.permission[1].checked)) && dogadoptionform.own[0].checked) {
alert('Landlords permission is a required question.');
event.returnValue=false;
}
.......
</script>

coothead
08-23-2009, 11:30 AM
Hi there mcolton,

try it like this...


<script type="text/javascript">
//<![CDATA[
function validate() {
mNv10=dogadoptionform.own.value;
mNv11=dogadoptionform.permission.value;

if (!(dogadoptionform.own[0].checked || dogadoptionform.own[1].checked)) {
alert('Own/Rent is a required question.');
event.returnValue=false;
}

if ((!(dogadoptionform.permission[0].checked || dogadoptionform.permission[1].checked)) && dogadoptionform.own[0].checked) {
alert('Landlords permission is a required question.');
event.returnValue=false;
}
.......

//]]>
</script>

Further reading:-

http://javascript.about.com/library/blxhtml.htm

coothead

mcolton
08-23-2009, 04:01 PM
From 33 errors to none. thanks

coothead
08-23-2009, 04:31 PM
No problem, you're welcome. ;)