Results 1 to 5 of 5
  1. #1
    kingyman is offline Member
    Join Date
    Mar 2013
    Posts
    3
    Rep Power
    0

    Default Help with validating a string

    Guys.

    My first java post, and my first attempt at trying to modify a java script.
    I have a small script that i'm trying to modify (below)
    This was originally to check if a field was empty or not, however, I'd like to modify it so it checks the
    existance of a specific string.

    I've played with the X== section, but i've now conceded that it's not as easy as i thought it would be.
    Ideally, i just want to create a challenge question, and the script will check if the answer is correct.

    Could anyone point me in the right direction please.




    <script>
    function validateForm()
    {
    var x=document.forms["myForm"]["answer"].value;
    if (x==null || x=="")
    {
    alert("Answer must be filled out");
    return false;
    }
    }
    </script>
    </head>


    <body>
    <form name="myForm" action="demo_form.asp" onsubmit="return validateForm()" method="post">
    Answer: <input type="text" name="answer">
    <input type="submit" value="Submit">
    </form>

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default Re: Help with validating a string

    Java != javascript! Go and find a javascript forum.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    kingyman is offline Member
    Join Date
    Mar 2013
    Posts
    3
    Rep Power
    0

    Default Re: Help with validating a string

    LOl.. shows what I know

  4. #4
    Slick Java is offline Member
    Join Date
    Dec 2012
    Posts
    11
    Blog Entries
    1
    Rep Power
    0

    Default Re: Help with validating a string

    Try this javascript forum: JavaScript frameworks - CodingForums.com
    Or learn JAVA - not javascript / html

  5. #5
    kingyman is offline Member
    Join Date
    Mar 2013
    Posts
    3
    Rep Power
    0

    Default Re: Help with validating a string

    Thanks for understanding.
    I am almost 50 lol

Similar Threads

  1. Validating log in using database
    By mDennis10 in forum New To Java
    Replies: 6
    Last Post: 03-11-2012, 12:17 AM
  2. Replies: 2
    Last Post: 11-30-2011, 04:41 PM
  3. Validating Jtable
    By anilkumar_vist in forum Advanced Java
    Replies: 1
    Last Post: 11-24-2009, 02:54 PM
  4. Validating for length of String
    By Bascotie in forum New To Java
    Replies: 1
    Last Post: 10-11-2009, 11:45 AM
  5. validating a string for numbers and letters?
    By lockmac in forum New To Java
    Replies: 1
    Last Post: 08-09-2007, 09:17 AM

Posting Permissions

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