I'm writing an app with Phonegap and I have a register form that is sent through ajax. It works fine when you hit the register button and execute the formcheck() function. However, when I hit the GO button from my android phone it submits the form instead of going through the formcheck() process. I tried:
<form id="RegForm" onsubmit="formcheck();return false;">
My form has no proper submit button but a button like this:
<input type="button" id="submitbtn" onclick="formcheck()"/>
I also tried to create a new OnSubmitForm() function that calls the formcheck() one but with no avail. Thank you for helping.
Found it!
1) Add this to the JS section:
$(document).ready(function() {
$("#YourFormName").submit(function() {
FormCheck();
return false;
});
});
function FormCheck() {
... validation process here ...
}
2) Make sure to include a Submit button in your form .. ( <input type="submit" )
Hope it'll help others so my 5 hour trying & testing time won't go wasted :)
Simply ensure your form tag is:
<form type='submit' onsubmit='return false;'></form>
This makes the submit action not do anything.
If you also need to hide the keyboard refer to How can I hide the Android keyboard using JavaScript?. A simple onsubmit='hideKeyboard(); return false;' will take care of this.
Related
I would like to make a Android function that would analyze the web content and automatically click the submit button and reload the page for updating. I have already get the on the webview and find the line of button. BUT I do not know what to do next. Anyone got ideas?
Try this by adding button with js to your html file:
<button onclick="myFunction()">Reload page</button>
<script>
function myFunction() {
location.reload();
}
</script>
Is it useful for you?You can use this to check checkbox, input value,... whatever with your webview?
http://executeautomation.com/blog/hybridapplication-robotium/
I am building an app with Meteor and I am looking to create a first time user launch screen- something like an "About/Welcome" page. Essentially, something that would pull a one-time screen after launching the app for the first time and never appear again; if the user has already opened the app they would be directed to another page.
I am not using login credentials, so I need a different solution than checking to see if the user is logged in or not.
How would I go about configuring this? I have tried searching all over the web and can't seem to find a solution for this. Please note this is different from a "Launch Screen".
You will need to either use localstorage, or set a cookie.
I'd suggest trying localstorage first. There are several packages on atmosphere that should help,
Using the frozeman:storage package (meteorpad example):
Template.body.helpers({
beenHereBefore: function() {
var beenHereBefore = LocalStore.get('BeenHereBefore', {reactive: false});
console.log(LocalStore.get('BeenHereBefore', {reactive: false}));
if (beenHereBefore !== true){
LocalStore.set('BeenHereBefore', true, {reactive: false})
console.log(LocalStore.get('BeenHereBefore', {reactive: false}));
}
return beenHereBefore;
},
});
<body>
{{#unless beenHereBefore}}
<h1> Welcome first time visitor! </h1>
{{else}}
<div class="outer">
<div class="logo"></div>
<h1 class="title">Leaderboard</h1>
<div class="subtitle">Select a scientist to give them points</div>
{{> leaderboard}}
</div>
{{/unless}}
</body>
Just some simple JavaScript should do the trick:
if (Boolean(localStorage.getItem('visitedApp'))) {
// user's been here before
} else {
// do stuff for first time user
localStorage.setItem('visitedApp', true);
}
Hello can someone please tell me how to create an click to email button that works on android? I have tried this (with mailto):
<input type="submit" value="Send Mileage" onclick="sendMileage()" />
.
function sendMileage() {
window.open('mailto:email#yahoo.com?subject=subject&body=body');
}
This works fine on my PC but when I put it on my appsbar app, download the app on android and then press the button it doesn't work, and says 'Web page not available'.
Can someone please tell me how to get this button to work on android?
Maybe by using:
window.location = "mailto:email#yahoo.com?subject=subject&body=body"
Since jquery mobile back button doesn't work well in different pages i have tried to add dynamic back button .Here's what i did
$("#page1").bind("pagecreate",function() {
if(page2 == 1){
$('<div data-role="button" id="back"><a data-icon="arrow-l" href="pag2.html">Back</a></div>').prependTo("div:jqmData(role='header')");
$("back").button();
}else{
$('<div data-role="button" id="back"><a data-icon="arrow-l" href="default.html">Back</a></div>').prependTo("div:jqmData(role='header')");
$("back").button();
}
}
when the button is prepend to the header its not having jquery mobile button styles it showsup like a plain link and moves all other header content down.Any help would be appericiated.
You need to enhance new markup with:
trigger("create")
Take a look at this jQuery mobile documentation.
Format of adding button to particular id is not,
$("back").button();
It should be,
$("#back").button();
If you are using class,
$(".back").button();
Kindly update your code. Hope this helps for your case.
I've got a search bar in a jQM/phonegap/cordova Android app.
How on earth do I detect when the user presses 'enter' or 'done' or whatever, so I can submit the search??
Do I have to build a custom key detector, or is there an event for this?
So frustrating - I can't find this in the docs anywhere....
Cheers all!
You would wrap the field in a form element ie:
<form id="foo">
<input type="text" />
</form>
Then to trigger an event when "the user presses the equivalent of 'return' on a PC keyboard i.e. 'go' or 'done', or whatever the OS has called it" you can use
$('#foo').submit(function(){
//do stuff
})
You would use the same code you would in a "normal" HTML application. Since you are using jQuery Mobile, you can use jQuery. If the field had an id of foo, you could use
$("#foo").on("click", function() {
//do stuff here
});