I have this form: http://lawb.co.il/HTMLPage.html
When someone click on the submit button ("שלח טופס" ) they are automaticaly redirected.
How can I prevent this action after clicking on the "שלח טופס" button, or that the page will redirect to a page that I choose and still I will get the information that people fill in the form?
The code is here http://jsfiddle.net/TCpkb/4/
Can you help me with it pleas?
You need to submit using AJAX and then redirect manually to your custom page. If you cannot use JavaScript, there is unfortunately no way to control the redirection if you let the user directly submit the HTML form.
Related
I am trying to upload an image to instagram's mobile website through selenium. It seems to find the element in question but when I try to submit it, the page merely refreshes.
uploadForm=driver.find_element_by_xpath('//*[#id="react-root"]/section/nav/div/div/form/input')
driver.execute_script("arguments[0].style.height='auto'; arguments[0].style.visibility='visible';", uploadForm)
#makes form visible
submitForm = driver.find_element_by_xpath('//*[#id="react-root"]/section/nav/div/div/form')
#selects whole form
driver.execute_script("arguments[0].style.height='auto'; arguments[0].style.visibility='visible';", submitForm)
#unhides form as well
uploadForm.send_keys("/testman.JPG")
#sends the file path to the input section of form
submitForm.submit()
#attempts to submit form, causing the refresh
Could there be some kind of JS listener preventing me from uploading this way? Here is the code of the form in question
Try doing a .click() on the submit button. Frequently, a dev will put a JavaScript onclick on the button that prevents the default action. You can see the default action for the form when the page "refreshes". The URL will contain your form as query-string parameter.
I have a form and I want to set focus on the status message when the form is submitted.
I have tried the following code.
$('form').on('submit', function(){
$('.messages--status').focus();
});
But the problem is that when I submit the form the page reloads and therefore my code is not working.
Is there any way to find on page reload that the form is submitted?
So that can I set the focus on the status message based on that condition?
Append a query parameter your url, and show the message based on that.
Eg. suppose your form action url is www.foo.com/form/submit then make it, www.foo.com/form/submit?submitted,
so when the page loads you can check whether submitted is there in the URL or not.
I need to submit a form with full refresh per CSJS in an event.
I know the solution to click the submit button. But is there a way to do it directly with JavaScript on client?
Thank you!
My workaround is to place a button with SSJS in a hidden div and then triggering it via CSJS. The button may do whatever you want, e.g. submit the form (save the datasource).
The cleaner approach would be to set the $$xspsubmitid with CSJS and then submitting the form. A possible way is described here: http://xpages.info/XPagesHome.nsf/Entry.xsp?documentId=88065536729EA065852578CB0066ADEC
I am trying to figure out a way to submit a form on my site, the form will load the same page, that is action="", after the form has submitted how can I make the page load at the point of the form? Instead of the page loading at the top like it does by default?
set an html anchor and use the anchor notation in the form action "mypage.html#myAnchor"
I don't know for sure if it works after a form post, but maybe you can use an anchor in the action url? (http://www.scribblegraphics.com/articles/articles-anchors.html)
I am using the jQuery MVC validation library for ASP.NET MVC, which is working fine.
However, on my form I have a 'Cancel' and a 'Save' button, both of which I want to submit the form back to the server.
However, if the user clicks 'Cancel' I need to disable the client side validation so that the user doesn't get prompted to complete required fields before they can cancel!
Any pointers would be appreciated!
Thanks.
I found a solution if you still have the same problem : step by step problem with validation on "back" button
Hope this helps!
So, when the user clicks cancel, what exactly you are expecting to happen? If you want to just redirect to a different page, then make sure the "cancel" button type is not submit and onclick of the cancel button, redirect to a different page. Button click will not validate the fields if it is not of submit type.