SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2004
    Location
    portoalto
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ClassName not working?

    Hi there,

    I have a form in a php webpage and when i submit the form i will validate the fields.

    If a field is not valid my idea was to change the css class of the input textbox to another one...else keep showing normal css class.

    I made something like this:

    <form....on submit="validade();">
    ...

    and i have a fuction like this...
    function validade()
    {
    mNv=formlogin.username.value;
    if (mNv=='') {

    alert('Username is a required field. Please try again.');
    document.getElementById("username").className='textfield2error';
    formlogin.username.focus();
    event.returnValue=false;
    return true;
    }
    else
    {
    document.getElementById("username").className='textfield2';
    }
    }


    but when this function works... the inputtext seems to change not to the css passed but it appears to loose all css and become a regular text box.

    what is wrong in the function?

    Regards

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What browser are you testing with? Is the page online so we can see it?


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
  •