cordova-ios icon indicating copy to clipboard operation
cordova-ios copied to clipboard

Html forms submit method is not working as expectation

Open TzHanChen1210 opened this issue 2 years ago • 1 comments

Bug Report

Problem

Html forms submit method is not working as expectation

What is expected to happen?

Should redirect the current page to the url which is setting at the action of attribute.

What does actually happen?

Nothing happening after trigger the submit method and no error appears in console.log

Information

Command or Code

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<form name="online" id="form" action="https://www.example.com" method="post" enctype="application/x-www-form-urlencoded" accept-charset="UTF-8">
<input type="text" name="RETURN_URL" value="example.com/callback">
<p class="edgeBox_Outer Adjust04"><input type="submit" id="submit" style="background: none; border: none; color: red; font-size: 90%;font-weight: bold; width:100%;" value ="Submit"> </p>

</form>
</body>
</html>

Environment, Platform, Device

Mac OS 13.3.1 iPhone 14 Pro - iOS 16.2 Simulator with Xcode 14.2

Version information

[email protected], [email protected], [email protected] [email protected] [email protected] Xcode 14.2

Checklist

  • [x ] I searched for existing GitHub issues
  • [ ] I updated all Cordova tooling to most recent version
  • [ ] I included all the necessary information above

TzHanChen1210 avatar May 27 '23 08:05 TzHanChen1210

An HTML form is probably not what you want to use in a Cordova application because:

  1. There is no "webserver" to locally post to to handle the post request, so it doesn't make much sense to post to a local URL.
  2. If you're posting to an external URL, then you're leaving your cordova application.

If you are posting to an external URL, that URL needs to be trusted in your allow list.

If you're integrating with an external server that uses forms, you can still use the JS Form API to submit the form without leaving the page.

breautek avatar Oct 21 '23 11:10 breautek