Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. Help me about validate form use javascript!!!

Help me about validate form use javascript!!!

Scheduled Pinned Locked Moved Web Development
javascripthelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cool_man
    wrote on last edited by
    #1

    I had a form like this: Type 1 Type 2 Type 3 Red Green Blue When Submit I want to use javascript check user had check at least one value in radio and checkbox but I dont want to use default "checked" for radio or checkbox. Can u help me, please? Thanks

    B 1 Reply Last reply
    0
    • C cool_man

      I had a form like this: Type 1 Type 2 Type 3 Red Green Blue When Submit I want to use javascript check user had check at least one value in radio and checkbox but I dont want to use default "checked" for radio or checkbox. Can u help me, please? Thanks

      B Offline
      B Offline
      Bee Master
      wrote on last edited by
      #2

      Include following 2 javascript functions & call CheckSubmit() on form submit. Hope this helps u.:~ function CheckObject(chkObj) { for(i=0;i<chkObj.length;i++) { if(chkObj[i].checked) return true; } return false; } function CheckSubmit() { if(!CheckObject(document.all("type"))) { alert("Please select a type"); return false; } if(!CheckObject(document.all("color"))) { alert("Please select a color"); return false; } return true; } Never comment ur code. If it was hard to write, it should be hard to understand !!!

      C 1 Reply Last reply
      0
      • B Bee Master

        Include following 2 javascript functions & call CheckSubmit() on form submit. Hope this helps u.:~ function CheckObject(chkObj) { for(i=0;i<chkObj.length;i++) { if(chkObj[i].checked) return true; } return false; } function CheckSubmit() { if(!CheckObject(document.all("type"))) { alert("Please select a type"); return false; } if(!CheckObject(document.all("color"))) { alert("Please select a color"); return false; } return true; } Never comment ur code. If it was hard to write, it should be hard to understand !!!

        C Offline
        C Offline
        cool_man
        wrote on last edited by
        #3

        Thank you very much :-)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups