37 users online (0 members and 37 guests)  


  Results 1 to 4 of 4

Related

  1. Problem With form validation of Postal Code    Forum: Javascript Forum
    Replies: 3
  2. Replies: 4
  3. Help with Javascript form validation please!!    Forum: Javascript Forum
    Replies: 2
  4. Form Validation Help Needed Please    Forum: Javascript Forum
    Replies: 1
  1. #1
    Team3's Avatar
    New User

    Status
    Offline
    Join Date
    May 2006
    Posts
    5

    Form validation - please help!

    Hi. I'm trying to do some form validation. I have three separate radio button fields, all can either be checked or unchecked and there results will determine what will happen when the form is submitted.

    This is what I'm doing:

    Code:
    <!-- Validating bit -->
    function myValidate() {
            if (form5.c2==1) {
           <!--    do whatever-->
                }
            if ((form5.c1==1)||(form5.c3==1)) { <!--do whatever -->}
            else {
              <!--  do whatever-->
                }
            }
    <!-- These are how my radio buttons are -->
    
    Yes<input type="radio" name="c3"  value="1">No<input type="radio" name="c3"  value="0">
    <!-- c2 and c3 are written the same-->
    
    <!-- Submit-->
    <input type="button" value="Submit" onClick="myValidate()">
    Someone please tell me whats wrong! Lol.

  2. #2
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: Form validation - please help!

    I can muddle my way through javascript, but one of the things that would help is if you told us what kind of error you're getting. Also, if I read your code correctly, it looks like you're missing a closing curly bracket on your function:

    Code:
    function myValidate() {
            if (form5.c2==1) {
           <!--    do whatever-->
                }
            if ((form5.c1==1)||(form5.c3==1)) { <!--do whatever -->}
            else {
              <!--  do whatever-->
                }
            }
    }
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  3. #3
    Team3's Avatar
    New User

    Status
    Offline
    Join Date
    May 2006
    Posts
    5

    Re: Form validation - please help!

    I don't get an error. This validation will be in an HTML/PHP page. When I load it up the validation just seems to do nothing. When I click the button with name Submit (I point that out because the button is not of type=submit) nothing happenes - which is where I thought the myValidator should kick-in and direct me as required. Sorry if I can't help you to help me more!

  4. #4
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: Form validation - please help!

    Personally I'd forget the javascript (because I'm rubbish at it!) and just pass the form as is to the handling page.
    Then I'd read the variables from $_POST, decide what to do and use the header("Location url") function to race off to the relevant page.
    That also allows you to redirect back to the form if there's missing or inappropriate data.
    If you want to do it that way and need a hand, just get back
    *edit* Forgot to say - this would be in PHP



Tags for this Thread