Web Analytics Made Easy -
StatCounter check &submit - CodingForum

Announcement

Collapse
No announcement yet.

check &submit

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    <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

    Comment


    • #3
      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. ;)

      Comment


      • #4
        I agree hehehehehehe
        Great new features this forum
        CYWebmaster.com - See why we dot com!!
        ACJavascripts.com - Cut & Paste Javascripts!
        SimplyProgram.com - Personal Blog

        Comment


        • #5
          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. ;)

          Comment


          • #6
            thank u

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

            Comment

            Working...
            X