Note that there are some explanatory texts on larger screens.

plurals
  1. POWebforms 4.5 default template and unobtrusive validation access validator to change css
    primarykey
    data
    text
    <p>I have created a new web application project using visual studio 2012 using .net 4.5. I have not changed any defaults or added anything other than what comes out of the box.</p> <p>I have read all over the web this included unobtrusive validation but can find any reference to it other than in the scripts folder webuivalidation which i am guessing is it, although through nuget there are lots of others. If i go to the register pager and click the button not filling anything in i get the default error messages, so again i am guessing its working. link to details about 4.5 script manager i have read <a href="http://blogs.msdn.com/b/webdev/archive/2012/09/21/asp-net-4-5-scriptmanager-improvements-in-webforms.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/b/webdev/archive/2012/09/21/asp-net-4-5-scriptmanager-improvements-in-webforms.aspx</a></p> <p><strong>What i want to do</strong> is to change the css from the default to bootstrap as shown in the below links:</p> <p><a href="https://stackoverflow.com/questions/10217175/mvc-twitter-bootstrap-unobtrusive-error-handling">MVC Twitter Bootstrap unobtrusive error handling</a></p> <p><a href="http://www.braindonor.net/blog/integrating-bootstrap-error-styling-with-mvcs-unobtrusive-error-validation/381/" rel="nofollow noreferrer">http://www.braindonor.net/blog/integrating-bootstrap-error-styling-with-mvcs-unobtrusive-error-validation/381/</a></p> <p>But using either or any method <strong>i get errors</strong> as i cant get the jQuery.validator object its undefined. Also if trying if $(this).valid() gives an error of not supported. So please can someone help and explain it to me as it appears the validate bits are not there?. I have tried for hours with no success or real understanding of the problem.</p> <p>Thanks Jon</p> <p>***** code bits ***</p> <p>2 bits of code i have tried from the above links, not written by me (i have tried editing but still couldnt get it to work):</p> <pre><code> $('form').submit(function () { if ($(this).IsValid()) { $(this).find('div.control-group').each(function () { if ($(this).find('span.field-validation-error').length == 0) { $(this).removeClass('error'); } }); } else { $(this).find('div.control-group').each(function () { if ($(this).find('span.field-validation-error').length &gt; 0) { $(this).addClass('error'); } }); } }); $('form').each(function () { $(this).find('div.control-group').each(function () { if ($(this).find('span.field-validation-error').length &gt; 0) { $(this).addClass('error'); } }); }); </code></pre> <p>Also:</p> <pre><code>jQuery.Page_Validators.setDefaults({ highlight: function (element, errorClass, validClass) { if (element.type === 'radio') { this.findByName(element.name).addClass(errorClass).removeClass(validClass); } else { $(element).addClass(errorClass).removeClass(validClass); $(element).closest('.control-group').removeClass('success').addClass('error'); } }, unhighlight: function (element, errorClass, validClass) { if (element.type === 'radio') { this.findByName(element.name).removeClass(errorClass).addClass(validClass); } else { $(element).removeClass(errorClass).addClass(validClass); $(element).closest('.control-group').removeClass('error').addClass('success'); } } }); $(document).ready(function () { $('span.field-validation-valid, span.field-validation-error').each(function () { $(this).addClass('help-inline'); }) }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload