go to next field automatically html5 form - javascript

I am using following html5 form.
<form>
<input type="text" name="orderno" />
<input name="picture" id="img" type="file" accept="image/*" capture="camera" />
<input class="btn-success" type="submit" name="submit" value="Upload" />
</form>
When I open this page in my mobile phone, I want that When I fill first input text, there should be a button called "NEXT" in my keyboard but currently it shows "GO" button directly. Any Help please?
javascript function document.getElementById('img').focus(); is not opening camera automatically.
I want the facility to launch camera on phone automatically when clicked "NEXT" or "GO" in keyboard.

For Security concerns, most browsers do not allow direct access to file uploader or image capture trigger. User has to click on the corresponding field to upload file or capture photograph. you can define focus after each has been addressed.

In first input have tabindex='1' in second input have tabindex='2' and so on.

Related

Remember input password dialog box, without reloading the page

I am searching a way to make the browser ask the user if he wants to remenber his password, when a form is submited without changing the current page (using the submit event for example).
I made a jsfiddle to show this: http://jsfiddle.net/HeFFh/2.
<form action="javascript:">
<input type="text" value="user" />
<input type="password" value="pass" />
<input type="submit" />
</form>
When you press the submit button, the browser should ask you if the password have to be remembered.
It only works with Firefox. Am I doing something wrong ?
It is based on browser settings and not on the code.
For chrome: goto -> settings -> show advanced settings -> Passwords and Forum -> Select "Offer to save passwords I enter on the web"
For more help visit this link
I believe you have to have the action attribute set to something other than "javascript:" and the inputs should have a name attribute.
Try this:
<form action="/" >
<input type="text" value="user" name="username" />
<input type="password" value="pass" name="password" />
<input type="submit" />
</form>
This will not override the browser setting, but will allow the feature to be used if it's not turned off by the user

Paypal Adaptive Payment - how to automatically complete the process

~~I am using paypals adaptive payments API to make a sale from my site.
I have gotten it to work, to a point.
I have set up my api credentials. I have gotten it to the point where I can click a button on my site to initiate a payment, my site makes a call to the Paypal server and I get the PayKey returned. According to teh documentation I have read,. I insert the paykey into a form, and set a trigger on the forms submit button to start the lightbox process.
However, my customer has already initiated the process when s/he clicked the original button, so I want the form with the PayKey to submit automatically. The problem with this is I dont know how to set the light box trigger.
My Form that needs to be submitted is:
<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame" name = "paypal_form">
<input id="type" type="hidden" name="expType" value="light">
<input id="paykey" type="hidden" name="paykey" value="RETURNED_PAYKEY_GOES_HERE">
<input type="submit" id="submitBtn" value="Pay with PayPal">
</form>
and I have a javascript trigger that starts the lightbox when the submit button is pressed:
var dgFlow = new PAYPAL.apps.DGFlow({ trigger: 'submitBtn' });
So if I press the button, the lightbox opens as required, however, I already initiated the sale when I pressed the button to get the PayKey, I dont want to have to press teh button again, and I have seen the lightbox process start on other sites without this second button click.
You can use javascript to submit the form. To make it easier, give the form an id, here's an example that uses jQuery:
<form id="paypal-form" action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame" name = "paypal_form">
<input id="type" type="hidden" name="expType" value="light">
<input id="paykey" type="hidden" name="paykey" value="RETURNED_PAYKEY_GOES_HERE">
<input type="submit" id="submitBtn" value="Pay with PayPal">
</form>
<script>
$('paypal-form').submit();
</script>

Customizing the appearance of a file input in an HTML form

I've been trying to figure out how to customize the appearance of a file input in an HTML form so that the button will match with the rest of the buttons on my site. Looking around here I found a solution that I would expect to work, but it's having some strange behavior.
I took my file input and set display:none, and created a new text input and button within the form.
<form method="post" action="../Entry/Create" enctype="multipart/form-data" onsubmit="return aentryValidate()">
<input type="text" id="EntryTitle" name="EntryTitle" maxlength="50" />
<div id="invalidTitle" class="invalidData"></div>
<p id="char-remaining">(50 characters remaining)</p>
<input type="file" id="ImageFile" name="ImageFile" style="display:none;" />
<input type="text" id="ImageFileMask" name="ImageFileMask" disabled="true" />
<button type="button" onclick="HandleFileButtonClick()" id="ImageFileButton" style="margin-left:10px;padding-bottom:0px;height:20px;width:100px;font-size:14px;">browse...</button>
<div id="invalidImage" class="invalidData"></div>
<p id="file-desc">(image to represent your entry, jpg, png, or gif)</p>
<textarea id="EntryDesc" name="EntryDesc"></textarea>
<div id="invalidDesc" class="invalidData"></div>
<br />
<input type="checkbox" id="isPrivate" name="isPrivate" value="true" />
<input type="hidden" name="isPrivate" value="false" />
Make my entry private.
<button id="new-entry-save">save</button>
</form>
Then my javascript to handle the ImageFileButton button being clicked:
function HandleFileButtonClick() {
document.getElementById("ImageFile").click();
document.getElementById("ImageFileMask").value = document.getElementById("ImageFile").value;
}
It appears to work fine. I click the button, the window pops up for me to select a file. When I select a file, it appears in the text box.
The weird behavior comes when I hit the save button on the form. I noticed that it has to be clicked twice to actually submit for some reason now. And, when it submits it is no longer posting the file.
So I made the file input visible again to see what was happening. If I use the ImageFileButton button to select a file, the file shows up in the file input. But when save is clicked, the file input clears and the form doesn't submit. You then have to click again to submit, and of course now there is no file.
Anybody know what is happening here?
No, its not possible. File inputs are generally browser dependant. You might have to use JavaScript replacement or Flash replacement like uploadify.
Article: Input File
Of all form fields, the file upload field is by far the worst when it comes to styling. Explorer Windows offers some (but not many) style possibilities, Mozilla slightly less, and the other browsers none at all. The "Browse" button, especially, is completely inaccessible to CSS manipulation.

JavaScript form submitting using an image is not working

I have a FORM that I want to use an IMG, instead of an input button, to submit the form.
The code:
<form>
<input class="form_grey" value="Enter in City or Zipcode" type="text" id="city-field" name="city" onfocus="this.value='';" />
<img src="/images/btn.png" />
</form>
When I type in the input field and Press ENTER (on my keyboard), the form submits correctly. BUT, if I type in the input field and click my image submit button, nothing happens.
Any ideas as to why my Javascript image form submit doesn't work?
Replace this:
<img src="/images/btn_search_listings.png" />
With this:
<input type="image" src="/images/btn_search_listings.png" />
Using Javascript to have an image submit a form is not really necessary here as you have the image input type that behaves as a submit button. This will also make keyboard navigation work properly and be much more accessible overall.

Tab order issue in IE with initial Javascript select of field in form

I'm trying to achieve the following behaviour in html: user is presented with a form involving several text fields. The fields are populated with default values, but in many cases the user will wish to enter their own. When the page loads, the value in the first field is selected, so the user can either replace it by simply starting to type and tabbing out to the next field, or simply leave it and tab out. Here's a pared down example of what I have:
<html>
<body onload="document.getElementById('helloField').select()">
<form>
<input id="helloField" value="hello"/><br/>
<input value="goodbye"/><br/>
<input type="submit" value="Submit"/>
</form>
</body>
</html>
This works in Chrome (and Firefox I believe, but I don't have it here). In IE, the field is selected as intended, but when the user hits tab, the browser tabs out to its address bar rather than to the goodbye field. If I replace the select with a simple focus, like
<body onload="document.getElementById('helloField').focus()">
the tabbing is okay in all browsers, but this isn't what I want. I want the user to be able to start typing right away to replace the default value.
Anyone have any ideas?
Thanks.
Focus, then select.
Also consider putting the code in a script block directly after the input in question. If you have a bunch of images on the page, document.onload can fire quite a lot later, and the last thing you want is to be typing away in an input box when onload fires and hijacks your focus (making you delete the contents of the box).
<input id="helloField" value="hello"/><br/>
<script type="text/javascript">
var hello= document.getElementById('helloField');
hello.focus();
hello.select();
</script>
Try setting the tab order of the fields using tabindex:
<html>
<body onload="document.getElementById('helloField').select()">
<form>
<input id="helloField" value="hello" tabindex="1" /><br/>
<input value="goodbye" tabindex="2" /><br/>
<input type="submit" value="Submit" tabindex="3" />
</form>
</body>
</html>

Categories

Resources