Results 1 to 4 of 4

Thread: & won't validate

  1. #1
    Join Date
    May 2009
    Location
    Greensboro, GA
    Posts
    163
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default & won't validate

    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:

    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>
    Last edited by mcolton; 08-23-2009 at 04:01 PM.

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there mcolton,

    try it like this...
    Code:
    
    <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:-

    coothead

  3. #3
    Join Date
    May 2009
    Location
    Greensboro, GA
    Posts
    163
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    From 33 errors to none. thanks

  4. #4
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    No problem, you're welcome.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •