Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
Here is the Code:
 <form id="form" method="POST" onSubmit="return submitForm()" data-ajax="false">
        <div class="XYZinfo">
        <label><b> XYZ Information</b></label><hr>
             <label for="firstname">First Name:</label>
            <input type="text" name="firstname" id="firstname" value="" placeholder="">
            <label for="lastName">Last Name:</label>
            <input type="text" name="lastname" id="lastName" value="" placeholder="">
            <label for="address">Address:</label>
            <input type="text" name="address" id="address" value="" placeholder="">
            <label for="apt">Apt:</label>
            <input type="text" name="apt" id="apt" value="" placeholder="">
            <label for="city">City:</label>
            <input type="text" name="city" id="city" value="" placeholder="">
</div>
 </form>

and the javascript code which i am using in the submit form is :


function submitForm()
 {

  var fname= $("[id='firstname']").val();
  var lname= $("[id='lastname']").val();
  var _address= $("[id='address']").val();
  var _apt= $("[name='apt']").val();
  var _city= $("[name='city']").val();

  window.localStorage.setItem("firstname",fname);
  window.localStorage.setItem("lastname",lname);
  window.localStorage.setItem("address",_address);
  window.localStorage.setItem("apt",_apt);
  window.localStorage.setItem("city",_city);

  if(fname == " ")
 {
alert('please the first name');
return false;
 }

else
  {
  $.mobile.changePage("#page2",{ reverse:false, transition:"slide"});

  $("#buyerData").html("FirstName:" + window.localStorage.getItem("firstname") +"<br>"+ "<br>LastName:" + window.localStorage.getItem("lastname") + "<br>" + "<br>Address:" + window.localStorage.getItem("address") +"<br>"+ "<br>Apt:" + window.localStorage.getItem("apt") +"<br>" + "<br>City:" + window.localStorage.getItem("city") );
  return true;
  }
}
Posted
Updated 2-Jul-14 1:18am
v2
Comments
Zoidberg Why Not 4-Jul-14 8:01am    
change if(fname == " ") to if(fname == "")

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900