dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Formvalidation problem Use of getPreventDefault() is deprecated. Use defaultPrevente

  1. #1
    Join Date
    Jan 2014
    Posts
    7

    Formvalidation problem Use of getPreventDefault() is deprecated. Use defaultPrevente

    Hi list,


    I have a form validation function that produces an error on the web console of Firefox:

    Use of getPreventDefault() is deprecated. Use defaultPrevented instead.

    I dont use use getPreventDefault() or defaultPrevented()
    The script is below.


    Any help would be greatly appreciated.


    j@n

    <script>
    function valf(frm)
    {
    var elems=frm.elements,
    len=elems.length,
    skipped='submit,reset',
    isvalid=true;
    if(!valf.ret)
    {
    valf.ret={};
    }
    var alfanum=/^[A-Za-z0-9]+$/;
    var resname=/^[A-Za-z0-9.*%]+$/;
    for(var i=0; i < len; i++)
    {
    if(skipped.indexOf(elems[i].type) !=-1)
    {
    continue;
    }
    else
    {
    var td=document.getElementsByName(elems[i].name)[0].parentNode.parentNode.cells[2];
    td.style.color='#fff';
    td.style.textAlign='center';
    td.style.fontWeight='bold';
    /*
    the code below checks only for empty values,
    so change the condition according to your needs
    alert(elems[i].value.length);
    */

    if(!elems[i].value)
    {
    td.innerHTML='<-- can not be empty';
    td.style.backgroundColor='Crimson';
    valf.ret[elems[i].name]=false;
    }

    else if(i == 0 || i == 2)
    {
    if (elems[i].value.length>8)
    {
    td.innerHTML='<-- too long';
    td.style.backgroundColor='Crimson';
    valf.ret[elems[i].name]=false;
    }
    if (!alfanum.test(elems[i].value))
    {
    td.innerHTML='<-- invalid character(s)';
    td.style.backgroundColor='Crimson';
    valf.ret[elems[i].name]=false;
    }
    }
    else if(i == 3)
    {
    if (elems[i].value.length>44)
    {
    td.innerHTML='<-- too long';
    td.style.backgroundColor='Crimson';
    valf.ret[elems[i].name]=false;
    }
    if (!alfanum.test(elems[i].value))
    {
    td.innerHTML='<-- invalid character(s)';
    td.style.backgroundColor='Crimson';
    valf.ret[elems[i].name]=false;
    }
    }
    else
    {
    td.innerHTML='OK';
    td.style.backgroundColor='Green';
    if(valf.ret[elems[i].name] != null)
    {
    delete(valf.ret[elems[i].name]);
    }
    }
    }
    }
    for(var k in valf.ret)
    {
    if(k)
    {
    isvalid=valf.ret[k];
    }
    }
    return isvalid;
    }
    </script>

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,674
    1 use the code tags for posting your code
    2 the described above bug is jquery related (see http://bugs.jquery.com/ticket/7535)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles