10 Replies Latest reply on Mar 20, 2014 9:00 AM by Sumetha

    validating value from a input text field

    Sumetha

      Hi I'm new to the Edge Animate and I have been working on a project that requires text input. The code does not 'recognise' the value entered into the input field. The action is quite straight forward, Correct Answer (360) play label 02, Wrong Answer play label 03. Ideally I would like allow three attempts.  I don't have much experience in JavaScript, this piece of code are bits and pieces that I have put together from tutorial and a bit of help.  Thank you and I appreciate all the help!

       

       

       

      var answer = sym.$("answer");

      answer.html("Answer 1");

      inputAnswer = $('<input />').attr({'type':'text', 'value':'', 'id':'answer'});

      inputAnswer .css ('font-size', 14);

      inputAnswer .css ('width', 150);

      inputAnswer .css ('background-color','#ffffff');

      inputAnswer .appendTo(answer);

       

      var submitBtn = sym.$("btn");

       

      function checkAnswer(){

       

      var rightAnswer = inputAnswer.attr('value');

       

      if (rightAnswer == "360")

                {

      sym.play("02");

                }

        else

                {

      sym.play("03");

                }

                return false;

      }

       

       

      submitBtn.click(function(){

               checkAnswer();

      });

       

       

      q.jpg