2

I am creating a jquery mobile app which has a form in it that posts data to an online server. When the form has an action attribute in it the form submits correctly and displays a message on the submission page. Although I have jquery attached to it to prevent it from navigating to the submission page as shown below.

<form data-ajax="false" id="codeVerification" method="post" action="http://domain.com/app.php">
    <div data-role="fieldcontain">            
        <label >Code</label>
        <input  type="text" placeholder="enter code" name="code" id="code"/>
    </div>
    <div data-role="fieldcontain">
        <button id="codeSubmit" >Submit</button>
        <input type="hidden" value="codeVerification" name="action"/>
    </div>     
</form>

and here is my test jquery code to prevent if from navigating to the submission page

$(document).ready ( function() {
    $("#codeVerification").on('submit', function(){
        alert('true');
        return false;
    });
});

I understand that data-ajax="false prevents the form from submiting via ajax. So again I have tried to remove the action attribute from the form, but it still doesn't working. when doing this on a browser the jquery code works but not in intel xdk.

What may I be doing wrong?

Daniel
  • 3,541
  • 3
  • 33
  • 46
shev
  • 41
  • 5

1 Answers1

0

remove the action="http://domain.com/app.php" in <form> and then the alert will work,

when u click submit, it is redirecting to http://domain.com/app.php so the event is not handled in javascript

krisrak
  • 12,882
  • 3
  • 32
  • 46