SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Grrrr ... radio button validation .. HOW !

    hi ..
    how ??
    i have 2 radio button, 1 must checked , HOW !

    Code:
    <input type="radio" name="stat" value="sold">
    <input type="radio" name="stat" value="rented">
    this code didn`t work !
    PHP Code:
    function validate_rec(theform) {
        if (!
    theform.stat.checked) {
            
    //if (theform.stat.checked = false) 
            //if (theform.stat.checked == false) 
        
    alert("Please select 1 of ...");
        return 
    false; }


  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
        if     (document.forms[0].stat[0].checked == || document.forms[0].stat[1].checked == 1alert('checked');
    else    
    alert('not checked'

  3. #3
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx alot ..

  4. #4
    long gone but not forgotten AljapaCo's Avatar
    Join Date
    Aug 2001
    Location
    Sweden
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm, itīs good programming to always have one of the choices selected...

    PHP Code:
    <input type="radio" name="stat" value="sold" checked="checked">
    <
    input type="radio" name="stat" value="rented"


    This would keept the SQL from cracking later...
    T O B I A S - S T R A N D H | visit my site here
    OPERA7 /MSIE6 /FireFox 1.1/Win2000 /ADSL /17" Screen /1024x768
    god doesn't create genius, he clones me.............


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
  •