Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Trouble with return false on a form submit.

    Hello everyone,

    This is my first post here, but reading through the others I'm sure someone will be able to help me.

    I trying to build a client-side validator before running my validation in php.

    I have a <form onSubmit="function(login name, login password)"> type deal and in my function, I'm returning false if certain criteria aren't met.

    the form's action runs it back to the current URL where I have a php validator activated if the post data is recognized.

    As of now, both are running, which tells me the form is being submit regardless of that return false.

    Can any of you make sense of it?

    Basically:
    <form onSubmit="myFunction()">

    Javascript:

    function myFunction() {
    get values of inputs

    run validator

    if it doesn't pass,

    return false;

    else return true;
    }

    shouldn't that return false stop the php validator?

  • #2
    New Coder
    Join Date
    Mar 2009
    Location
    Fabric Covered Box
    Posts
    69
    Thanks
    1
    Thanked 16 Times in 14 Posts
    Your validation function is returning true/false, but you're not passing that result to onsubmit. Try
    Code:
    <form onsubmit="return myFunction()">


  •  

    Tags for this Thread

    Posting Permissions

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