Grails Client Side Form Validation - grails

if I click the submit button without picking a file, the form will still submit to the upload action. For Grails, would you teach me how to validate myFile to make sure myFile is not empty before the form submit to the upload action please?
Thanks!
<g:uploadForm name="uploadForm1" action="upload">
<input type="file" name="myFile" />
<input class="save" type="submit" value="Import" />
</g:uploadForm>

Related

Messenger Bot: Webview form action

I have a chatbot and I want to use webview forms when the "survey" is "non-linear"
I have this form. What to "place" in the action if I want to tell the bot to catch the data?
<form action="I SEARCHING FOR THIS" method="GET">
<input type="text" name="foo" placeholder="foo" />
<input type="text" name="bar" placeholder="bar" />
<button type="submit">SUBMIT</button>
</form>
Action should be sent to the URL for your webhook. Also, if you are sending data you should POST not GET.

Rails - raw() removing FORM from content field data

I have a text field that stores page content created with a WYSIWYG HTML Editor.
Text field (content):
<form accept-charset="UTF-8" action="/myaction" method="post">
<input name="myaction[product]" type="hidden" value="Other" />
<input name="myaction[product]" type="hidden" value="Car" />
<input class="btn btn-primary" type="submit" value="Get a Car"/>
</form>
Show page
<% highlight(raw(#page.content),params[:search]) %>
The form does not seem to display or show the bootstrap form and button. It seems to be getting removed. What can I do to get the form to display?

How do I setup Auto Return URL for a PayPal Buy Button?

I am using the html code for a simple Paypal buy button but was wondering if it's possible to setup an auto return url without having to do it through my own Paypal account itself?
I can't do it that way because it is a localhost website (cannot validate a real website) and I'm not creating a button through my selling tools.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="email#email.com">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Demo">
<input type="hidden" name="amount" value="0.01">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="return" value="~/">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0" src="https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif">
</form>
Yes you can set your own return URL. HTML Special Variables. You can add this code to your form.
<input type="hidden" name="return" value="http://localhost" />
In your html you are defining a relative path to your home directory but you will need an HTTP or HTTPS url for it to work. This is because the page that the paypal checkout is on is not in your root directory, so it needs a specific location.

How do I add a hidden input tag using the Jericho HTML Parser?

For each form in an HTML page I want to add an additional hidden input tag as it passes through a JEE Filter. For a given HTML page for example:
<html>
<form name="input" action="submit.jsp" method="post">
<input type="hidden" name="id" value="1"/>
<input type="submit" value="Submit"/>
</form>
</html>
the end result should be similar to this:
<html>
<form name="input" action="submit.jsp" method="post">
<input type="hidden" name="id" value="1"/>
<input type="submit" value="Submit"/>
<input type="hidden" name="dynamickey" value="DYNAMIC_VALUE_HERE"/>
</form>
</html>
As the HTML may be malformed, I am figuring that Jericho would be the HTML parser of choice. After a couple of passes through the web pages, I have found ways to change the values of already existing tags, but how to add an additional tag escapes me.
Thanks in advance for help.

Empty Request.Files with MVC 3 file upload

This is my markup:
<form action="/Customer/Create" enctype="multipart/form-data" method="post">
<input id="file" type="file" style="width:300px" />
<input type="submit" id="btnSubmit" value="Add Image to S3" />
</form>
When I step through the Create action the Request.Files is empty. I've searched and searched and all the advice seems to be about ensuring the enctype is set to "multipart/form-data" which I have already set. Any other ideas?
Try adding a name attribute to the input. I don't think nameless form items get posted at all.

Resources