Results 1 to 2 of 2

Thread: Stop a form from submitting [Resolved]

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    Resolved Stop a form from submitting [Resolved]

    I want to check to make sure a field is filled in before the form will submit.

    I have this:
    Code:
    function checkforinitials()
    {
        if (document.dform.INIT_BADGE.options[document.dform.INIT_BADGE.selectedIndex].value == 'na')
    		alert("Please fill in your initials at the top of the form!");
    	return false;    
    }
    Which works when called by this, except that the form still gets submitted when the error message pops up:
    Code:
    <form name='dform' action='submitcal.php' method='post' onsubmit='checkforinitials();'>
    However, the submission is done via PHP. How do I stop the page from going through the submission when they haven't filled that item in?
    Last edited by ober0330; Jan 18th, 2005 at 02:58 PM. Reason: Question Resolved
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  2. #2

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    Resolved Re: Stop a form from submitting Resolved

    Nevermind. I just had to put "return functionname();" in the onsubmit.
    Last edited by ober0330; Jan 18th, 2005 at 02:57 PM. Reason: complete
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

Posting Permissions

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



Click Here to Expand Forum to Full Width