Log in

View Full Version : Form validation (required fields) only working in firefox and not in IE or Safari



magnetik12
03-25-2013, 02:03 PM
I was wondering if anyone could help? This isn't using a DD script but instead originated as a basic form from wufoo. From there I copied the code and built on that, adjusted the css accordingly etc.

It submits to email with no problems, that part is fine. However there are around 9 required fields, in firefox if any of these are left blank the form doesn't submit and the required fields are highlighted (doesn't look the best but will look at that afterwards) however in IE or Safari it doesn't validate at all and just submits to the 'thanks for contacting us' message. I can leave the form completely blank and it goes through ok in these browsers!

Have googled it and people have similar issues but not the same so can't find an answer. In those cases it seems to be quite an easy fix with an adjustment to the script.

any help would be appreciated, it's my own fault for trying to take shortcuts!

EDIT: It validates as normal on chrome too.

vwphillips
03-25-2013, 04:08 PM
please post a link to your page

magnetik12
03-25-2013, 04:18 PM
Oh sorry, I meant to do that! http://www.paycoservices.co.uk/SU_reg2.asp#.UVB4vaWduS0

Thanks

magnetik12
03-26-2013, 06:10 PM
I think this may be better in the asp forum as it is a site built using .asp.

Shall I re-post in there or can someone move it?

iqraaquran
04-24-2013, 10:16 AM
try this code probably it will be helpful to you

<xhtmlConformance mode="Legacy"/>
set in your web.config, then client-side validation is disabled in firefox.

To see why, we have to jump down into the validation framework that ASP.Net sends to the web browser. The actual Javascript validation function looks like:


function ValidatorValidate(val) {
val.isvalid = true;
if (val.enabled != false) {
if (typeof(val.evaluationfunction) == "function") {
val.isvalid = val.evaluationfunction(val);
}
}
ValidatorUpdateDisplay(val);
}

This produces a block of Javascript just before the closing </form> tag like:


<script type="text/javascript">
<!--
var TextBox1 = document.all ? document.all["TextBox1"] : document.getElementById("TextBox1");
TextBox1.value = "";
// -->
</script>