Jump to content

Add required field validation on a Text Profile Attribute


Ryan_B

Recommended Posts

Good morning MarcomCentral community.

 

After trying for most of yesterday and a good part of this morning, I've decided to finally reach out for help. What I'm trying to accomplish is set a required field validator on a Text Profile Attribute that I've created. I need to capture the users bill to address after they've registered as a new user. If a new user visits the portal/site, after they register I have them being redirected to the Profile page. From there I'm trying to get them to fill out an attribute field before moving on to the catalog, etc. The reason being is because our system that is in place that connects MarcomCentral to our systems, printers, invoicing, etc. will error out without that bit of the users information.

 

This seems like it should be a pretty simple piece of code, however I can't seem to make it work. Here's a couple things I've tried thus far:

 

The Uncaught TypeError I receive when trying this is supposedly fixed by wrapping the code in window.onload (according to Stack Overflow), but I still receive the error.

<script>
var required = document.getElementById("ctl00_content_TextUserAttributeList_btnContnue");

window.onload = function(){

    function isRequired(){

         $j("#ctl00_content_TextUserAttributeList_9086672").attr('required',true);

    };

    required.click = isRequired;//Uncaught TypeError: Cannot set property 'click' of null

};
</script>

 

This is pretty much the same error, and attempt at fixing it. Obviously to no avail.

<script>
var required = document.getElementById("ctl00_content_TextUserAttributeList_btnContnue");

window.onload = function(){

    required.onclick = function(){//Uncaught TypeError: Cannot set property 'onclick' of null

         $("#ctl00_content_TextUserAttributeList_9086672").attr('required',true);

    };

};
</script>

 

 

I am still very new to JavaScript and MarcomCentral, (I'm actually flying out this Sunday to Solana Beach, CA for a week long training at PTI). But this seems like something I should've been able to figure out. I feel like I'm right there, I just need that extra little "push" in the right direction. If there's anyone out there who has done this, or might know how to, I'd sure appreciate the help. Thanks in advance.

Link to comment
Share on other sites

×
×
  • Create New...