Can we submit an html post form in react-native? - javascript

I have a question if we can submit an html post form with Linking in react-native. If yes how we can submit it?
I want to submit it to default browser (not with webview) and here is html form:
<form method="POST" target="..." id="..." :action="videoConferenceUrl">
<input type="hidden" name="target" value="..."/>
<input type="hidden" name="requestOrigin" value="..."/>
<input type="hidden" name="username" :value="..."/>
<input type="hidden" name="password" :value="..."/>
<input type="hidden" name="eventID" :value="..."/>
</form>
Please write every way how we can submit that form in the default browser.
Thanks in advance.

Related

Form inside angular component does not submit

I have a classic html form element which works fine when I insert it into the index.html of an angular application. A click on the button submits the form. If I insert the same form in an angular component html file, it is rendered as well but when I click the button, nothing happens.
<form method="post" action="https://blub.shtml" id="form" name="form" target="_parent">
<input type="hidden" name="data" value="data" />
<input type="submit" value="Send" />
</form>
Why does this happen and how can I fix it?
EDIT: I cant use (ngSubmit) because of the CORS policy of the server.
Try this approach to see if it work
<form method="post" action="https://blub.shtml" id="form" name="form">
<input type="hidden" name="data" value="data" />
<button type="submit"/>Send</button>
</form>
Try this
<form ngNativeValidate (ngSubmit)="onSubmit()" #form="ngForm">
and in onSubimit method you can to whaterver you want.

How to have button in the form which check for required fields on submit but does not refresh the page?

I need to have a form with a button which on submit, check for required field but does not refresh the page.
<form>
<fieldset>
<input type="text" id="firstname" placeholder="First Name" required/>
<input type="submit" value="Send"/>
</fieldset>
</form>
If I disable on submit for form, it wont check for required fields anymore. I need all the functionality of onSubmit but without refreshing the page.
I will appreciate any help.
I'm unsure why you are getting an error. The code provided should work. Try adding an action and a method just in case as follows:
<form action="" method="POST" onsubmit="myFunction()">
<fieldset>
<input type="text" id="firstname" placeholder="First Name" required>
<input type="submit" value="submit">
</fieldset>
</form>
You can then add a function called myFunction down below as follows:
<script>
function myFunction() {
alert("Form was submitted");
}
</script>

Is hiding the post button a valid way to prevent a user from posting without permission?

I have some comment forms that I want to not be used unless the user is logged in with Google+. I initially have the "submit" button on my forms hidden by the CSS display:none property. I call javascript when the user logs in to change it back to display:inline.
Is this a valid way to prevent anonymous users from posting, or am I still vulnerable by leaving the rest of the comment form open for writing and whatnot...is there some clever way to submit the form without the submit button?
<form action="" method="post" name="form1" id="make">
<fieldset>
<legend id="makelegend">Log in to Post a Reference</legend>
<input type="hidden" name="loginname" id="loginname" />
<input type="hidden" name="logintype" id="logintype" />
<input type="hidden" name="loginspecial" id="loginspecial" />
<input type="hidden" name="reply" id="reply" value="0" />
<input type="hidden" name="identity" id="identity" value="<?php echo htmlspecialchars($_GET['pageno']); ?>" />
<p><label for="posneg">Positive or Negative?
<select name="posneg">
<option value="p">Positive</option>
<option value="n">Negative</option>
</select></label></p>
<textarea name="comment" rows="5" cols="70"></textarea>
<input type="submit" id="submitter" value="POST" style="display:none;" />
</fieldset>
</form>
It is ABSOLUTELY NOT safe! You're just not displaying the data to the user, but anyone who looks at the code can still find it - or just send the request manually. I can't stress this enough: ALWAYS use server-side validation! It's fine to validate things in the browser as well, but it's not a substitute for proper security measures.

Simulate a submit button click via JavaScript

Is it possible to Submit a form with JAVASCRIPT? if yes please help me...
I have a form with input fileds in it. So I want javascript to count if all fields are field in and then press on the submit button.
The submit button "Save" will be hidden from visitors eyes.
<form id="my form" action="">
<input type="text" name="fname" id="fname" value=""/>
<input type="text" name="sname" id="sname" value=""/>
<input type="text" name="email" id="email" value=""/>
<button type="submit" name="submitAccount" id="submitAccount">save</button>
</form>
here is a opened FIDDLE
Thanks to all for any help!
you can submit form via JavaScript even without submit button, form element has method .submit() which submits whole form.
var myForm = document.getElementById('myform');
myForm.submit();
Before submiting form you can get values from every field in form and make you own validation.
P.S. don't use values for id attribute with whitespace, you should rename it to 'myform' or 'myForm'.
There is a required attribute
<form id="myForm" action="">
<input type="text" name="fname" id="fname" value="" required/>
<input type="text" name="sname" id="sname" value="" required/>
<input type="text" name="email" id="email" value="" required/>
<button type="button" name="submitAccount" id="submitAccount" onclick="checkForm();">save</button>
</form>
Form gets submitted only if the required fields are filled

While submitting a form IE8 won't add attributes to the request other than those from inputs

All other browsers (including IE9, exluding ancient ones) send correct requests for the following form:
<form class="form-submitter form-horizontal" enctype="multipart/form-data" name="Uploader" id="Uploader" action="MainServlet?module=general&action=add&Name=test">
<input class="input-file" name="testFormName" id="UploaderInput" type="file">
</form>
That is:
http://localhost:8080/Project/MainServlet?module=general&action=add&Name=test&testFormName=%5Bobject+File%5D
while in IE8 all I get is:
http://localhost:8080/Project/MainServlet?toSessionFormName=test.png
I'm using jQuery's submit, that is:
$("#Uploader").submit()
I'd love to get any suggestions, or tips which could lead to me to solution. Did anyone has this problem already with IE8?
Thx
Use hidden inputs :
<form class="form-submitter form-horizontal"
enctype="multipart/form-data" name="Uploader" id="Uploader"
action="MainServlet">
<input type=hidden name=module value="general">
<input type=hidden name=action value="add">
<input type=hidden name=Name value="test">
<input class="input-file" name="testFormName" id="UploaderInput" type="file">
</form>
That's the right solution. You'll even avoid encoding problems.
Can you change your code this way:
<form class="form-submitter form-horizontal"
enctype="multipart/form-data"
name="Uploader" id="Uploader"
action="MainServlet" method="get">
<input class="input-file" name="testFormName" id="UploaderInput" type="file">
<input type="hidden" name="module" value="general" />
<input type="hidden" name="action" value="add" />
<input type="hidden" name="Name" value="test" />
</form>
It is better to implicitly send the parameters through GET rather than in URL.

Categories