Skip navigation
Immaculate Mackerel
Currently Being Moderated

Toggle spry textfield verification with javascript?

Jul 6, 2012 3:35 AM

Tags: #dreamweaver #javascript #spry #ajax

Hi I originally posted this in the dreamweaver forum but this forum seems more applicable to my question

 

So I have a checkbox on this form that when clicked will execute a script requiring certain fields to be validated, I had also set it so that if the box was unchecked  the fields would no longer be required which would work but once the script is run then it wont submit the form without a value being placed in the fields and I'm not sure where exactly to look in the textfield and selectvalidation.js files to allow for blank values to be submitted or perhaps there is a better way to go about what I'm trying to do

 

 

The script in question

<script type="text/javascript">

 

function CheckCheckbox()

 

{

 

    var elLength = document.registrationform.elements.length;

 

 

 

    for (i=0; i<elLength; i++)

 

    {

 

        var type = registrationform.elements[i].type;

 

        if (type=="checkbox" && registrationform.elements[i].checked)

 

{

 

        var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2");

 

var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["blur"]});

 

var sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11", "none", {validateOn:["blur"]});

 

var sprytextfield12 = new Spry.Widget.ValidationTextField("sprytextfield12", "none", {validateOn:["blur"]});

 

var sprytextfield13 = new Spry.Widget.ValidationTextField("sprytextfield13", "none", {validateOn:["blur"]});

 

var sprytextfield14 = new Spry.Widget.ValidationTextField("sprytextfield14", "none", {validateOn:["blur"]});

 

var sprytextfield15 = new Spry.Widget.ValidationTextField("sprytextfield15", "none", {validateOn:["blur"]});

 

var sprytextfield16 = new Spry.Widget.ValidationTextField("sprytextfield16", "none", {validateOn:["blur"]});

 

        }

 

        else if (type=="checkbox")

 

{

 

var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2", {isRequired:false});

 

var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {isRequired:false});

 

var sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11", "none", {isRequired:false});

 

var sprytextfield12 = new Spry.Widget.ValidationTextField("sprytextfield12", "none", {isRequired:false});

 

var sprytextfield13 = new Spry.Widget.ValidationTextField("sprytextfield13", "none", {isRequired:false});

 

var sprytextfield14 = new Spry.Widget.ValidationTextField("sprytextfield14", "none", {isRequired:false});

 

var sprytextfield15 = new Spry.Widget.ValidationTextField("sprytextfield15", "none", {isRequired:false});

 

var sprytextfield16 = new Spry.Widget.ValidationTextField("sprytextfield16", "none", {isRequired:false});

 

        }

 

        else {

 

 

 

}

 

    }

 

}

 

</script>

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points