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 6 of 6

Thread: check &submit

  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb check &submit

    {
    if (form1.fn.value ="")
    {
    alert("you must type your name")
    return false
    }
    }
    //-->
    </script>
    <form onsubmit="return check()" action=confirm.asp method=post name=form1 >

    please fill the folowing form
    First Name
    <input name=fn >

    <INPUT type="submit" value="Submit" name=submit1>


    ****************************************************
    in prvious code i want to first to check if the text box is embty or not ,so it submit the form to asp file.
    when i try the code it submit the form to asp without checking it
    why??

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <script language="javascript">
    function check(){
    if (document.form1.fn.value=="")
    {
    alert("you must type your name")
    }
    }
    //-->
    </script>
    <form action="confirm.asp" method="post" name="form1">


    <input name="fn">

    <INPUT type="submit" value="Submit" name="submit1" onclick="check()">

    -------
    Heres why it didn't work

    1).value="" (incorrect)
    should be .value==""
    one = means that you are writing to the form.
    two == means that it already has a value and you are checking it

    2) "" always put quations "" around names and actions.


    I hope this has helped.


    HappyScripting
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would reply but I think AC has covered it
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I agree hehehehehehe
    Great new features this forum
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also make sure that your onsubmit statement matches the function name and that it returns a boolean value (true or false).

    If you're still having problems please post in return.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thank u

    thanks for all
    it is worked correctly
    meny function include(this) word
    why?


  •  

    Posting Permissions

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