I am using this plugin:
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
To validate a form that is hosted on a different server from my development site. All the validation scripts are on that document and appear to be working fine.
http://forms.icis.com/content/CHX0041_RequestFreeTrial
I am using an iframe to pull in the form from the external site but when i try and submit the form and fire the validation script it is not working. It just submits the form as if there was no validation at all.
The iframe sits within a CMS page that is contained in another form so i thought the issue may be there. This fiddle demonstrates the issue:
http://jsfiddle.net/We78c/
EDIT
It seems as though removing the URL paramaters from the iframe src fixes the issue:
http://jsfiddle.net/We78c/2/
However i need them so as to pass them through to some hidden input variables in the child iframe. Is this a known issue?
In your form you're setting the method="#" and action="post". The method should be method="post" and action should be the url where you're posting.
There was a JS error causing this to fail the validation. Commented out and seems to be working now.
Related
I use an iframe on my page, which consists of a form with input elements.
Every input element has an onblur() event, which validates the input.
When I open the page in IE 8 with a freshly cleared cache it produces a javascript error like this.
document.getElementById(...)' is Null or not an Object
However, when I inspect the form it is loaded completely and the I'm trying to access is rendered.
Furthermore when i reload the whole page I don't get any errors anymore.
Also when I load the content of the iframe on its own I also don't get errors.
Firefox and Chrome dont throw errors at all.
In short, the Javascript errors I get only occur in IE and only when I use an iframe to display the form (which is mandatory) and only when the page is loaded for the first time.
Any ideas on how I can fix this?
I hope its not too confusing to read.
Edit:
document.getElementById("vHint_"+fieldName).innerHTML=data;
FieldName is the id of the input field. Data is the return value of the validation.
In this case data is an image tag.
After every input field is a span Tag with the id "vHint_"+fieldName.
The event is attached like this:
<input id="Jahr" class="input" type="text" onblur="validDate(this,'Jahr','_beginn')" maxlength="4" style="width:32px" value="" name="Jahr">
First of all thank you for your effort.
The example user13500 provided worked like a charm.
And it made me dig deeper.
And i found the solution.
All input fields are created with a self made ASP Framework, which puts them all in the Session.
The onblur() event of the input field within the iframe triggers an AJAX Request to an ASP file passing the name of the input field as a request parameter. The ASP file now tries to find the field in the Session and retrieve its value to validate the input.
After that the result is posted back to the javascript file, which then uses document.getElementById("vHint_"+fieldName).innerHTML=data; to post the result back in the page.
This normally works without erros.
But, since the application is run in an iframe and the domains of the surrounding page and the application in the iframe are different, IE rejects the Session of the iframe. Thus the result of the ASP validation is empty, because it couldn't find the field in the Session.
Having figured that out the only thing that has to be done is to add this line of code in the application:
Response.AddHeader "P3P", "CP=""CAO PSA OUR"""
This way IE doesn't reject the Session of the application anymore.
Maybe this can be useful for others too.
So I'm pasting in some code for a form from Salesforce.
This code to be specific: (from the style element to the end of the form) https://gist.github.com/13ab0efd07c2c8cdb3e1
When clicking submit while not filling out any or all fields, I get a form validation check and then a message will popup with the fields that I have not filled out.
However, when I paste the code into our LightCMS template the form validation is not working and just redirects to the thankyou page as if everything went through fine.
They use LightCMS. And even when link to an external js file instead of embedding the js I still get the same results.
I've noticed it adds an "onclick" element on the Submit button on the front-end but it only does that when it's in the CMS not on a bare bones HTML page.
Any thoughts?
i think you should add this
onsubmit=return formvalidator(Document.getElementByid(search-form))
before form action because it will check the form before submitting it. if check fails the action will not occur.
I have the oddest bug. I have a simple html form. You can see it here:
http://www.learndoearn.org/almost_real_products/food_services.html
This form is just for demonstration purposes only. It doesn't really submit to anywhere. All I want it to do is validate a few fields and if those fields are filled in, redirect the user to a thank you page. This works fine if you physically click on the html file to open it, HOWEVER...if you try to access this html page via the domain name (as seen in the link above), clicking the submit button (once all necessary fields are filled in) doesn't work. It simply doesn't do anything.
The redirection to the thank you page occurs in this file:
http://www.learndoearn.org/almost_real_products/js/forms.js (it's about halfway down the js file where it says window.location = "http://www.learndoearn.org/almost_real_products/thanks.html";
Any idea what I'm doing wrong?
Thanks
The link you have provided to the ajax call "bin/MailHandler.php" is returning a 405 error. Due to this the success function is not being run and the redirect does not take place.
Modify your php file to return success irrespective of the input if its a dummy and it should all work fine.
I have a form I am submitting with form.submit() to a hidden iframe. I then take the result and process the data.
If the result fails (validation errors) then I display an error in a div tag.
The problem I have is that if you press the submit button again the form submits to a new tab.
I tried form.reset(); // just resets the form.
I have tried resetting the target of the form to the hidden iframe again but that doesn't seem to work either.
I tried this a long time back.
The trick was to set the target of the form to hidden iframe using html and not JS. What I mean is, you should do:
formContainer.html("<form target='iframe_name' .... />");
However,
get_form_by_id.setAttribute("target","iframe_name")
didn't provide the desired result.
(There shouldn't be a reason for it, however speaking from experience, I faced this issue when designing an IE compatible website and this was the solution that worked).
First I am new to the asp .net world and am trying to figure out a weird issue that I am having. Any suggestions or comments are welcome.
I have a page that has a form and on submit I launch another aspx file that exists in the same directory.
The problem is the aspx file is shown and the file closes immediately!.
Howewever, the weird part is if I make any modifications to the aspx file and save it and then run my application it works fine ONLY THE FIRST TIME!? any subsequent submit actions launch the aspx page but then the aspx file immediately closes.
But after I make some modifications to the aspx file..(simple ones) it launches correctly the first time.
I realize that this is very little info to go on and I am not even sure if I have got my point across...but any suggestions on how to debug this will be helpful.
We are targetting .net version 4.0 and using IIS7.
I am thinking that the asp worker process is doing something weird like checking for timestamps and closing it?! Not sure tho.
Any help is appreciated.
ASP.Net webforms don't use the form in quite the same way as regular HTML forms. All you need in your form tag is
<form runat="server">
If you want to pass the user onto another aspx page you can use the Response object:
Response.Redirect("~/pages/SomeOtherPage.aspx");
or (Server.Transfer - read up on the differences)
Server.Transfer("~/pages/SomeOtherPage.aspx");
If you want to open a page in a new/pop-up window or similar you'll need to do so using JavaScript
window.open('/pages/SomeOtherPage.aspx') [There are overridden versions of this method]
You can use the forms PostbackUrl property too, but this will also keep the user in the same browser window. More info here.
HTH