Results 1 to 2 of 2

Thread: Trying to match submit and onblur functionality

  1. #1
    Join Date
    Feb 2014

    Question Trying to match submit and onblur functionality

    I have a form with a single field and as part of my learning, I created a simple functionality using the blur function of jquery - which happens to work as expected. However, the form resets after I hit the submit button. I want to modify such that blur function code works on submit as well. I presume this must be pretty simple, but I just don't have the knowledge to do and something I could not figure out using google searches. Can somebody provide any tips/suggestions? Not sure if this forum allows posting HTML code, but I will try below. In the code below, I would like to continue increase the value of intGuesseSoFar during each try of the user (when it is not blah). If it blah, I want to reset the form.
    Thanks all.

    <!DOCTYPE html>
    <title>WD - Assignment1</title>
    <link rel="stylesheet" type="text/css" href="wdtest.css" />
    <link rel="stylesheet" type="text/css" href="RMSforms-v0.5.css" />
    <script src="jquery.js"><script>
    <script src="app.js"></script>
    nIncorectGuesses = 0;
    $(document).ready(function() {
    console.log("in ready function - " + nIncorectGuesses );
    console.log("in blur function - " + nIncorectGuesses);
    if ($('#yourGuess').val().toLowerCase() != "blah") {
    console.log("in if condition - " + nIncorectGuesses);
    <div class="formConatiner">
    <form id = "testform">
    <ul class="form">
    <li class="leftNote"><label>Your Guess</label><input type="text" id="yourGuess" name ="yourGuess" /></li>
    <p>Number of guesses so far: <output id="intGuesseSoFar" name = "intGuesseSoFar"/></p>
    <input type="submit" value="Play" id='play';">

  2. #2
    Join Date
    Mar 2007
    Try asking in the JQuery (JavaScript Frameworks) forum.
    If your post falls off the page, bump it. ...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Recent Articles