wtorek, 28 grudnia 2010

Globalizing ASP.NET MVC unobtrusive validation

If you want to globalize unobtrusive jQuery valdiation in your ASP.NET MVC3 the post by Phil Haack won't do the job for you. Still it's quite simple to do.

First of all you'll need to download jquery-glob and place globalization.js and Globalization.xx-XX.js in your Scripts folder. Then you need to include them after regular validation scripts. Below is an example of how it should look:

<script src="/Scripts/jquery-1.4.1.min.js" type="text/javascript">
</script>
<script src="/Scripts/jquery.validate.min.js" type="text/javascript">
</script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript">
</script>
<script src="/Scripts/globalization/globalization.js" type="text/javascript">
</script>
<script src="/Scripts/globalization/Globalization.pl-PL.js" type="text/javascript">
</script>

In my case the globalization script is: Globalization.pl-PL.js since that's the locale of my customer and his web application.

After that if you want the validator to format the numbers correctly you'll need to add the following code to 'tell' the validator what function to use when validating number format:

<script type="text/javascript">
    $.validator.methods.number = function (value, element) {
        if (Globalization.parseFloat(value)) {
            return true;
        }
        return false;
    }
    $(document).ready(function () {
        $.culture = jQuery.cultures['pl-PL'];
        $.preferCulture($.culture.name);
        Globalization.preferCulture($.culture.name);
    });
</script>

Now your validation client will pass when you input number like 12,90 (PL) instead of 12.90 (EN).

I noticed that you can't use the jQuery version of the Globalization plugin. There's a naming conflict between jQuery.validate.format and jQuery.glob.format.

środa, 22 grudnia 2010

Strona dla doradców finansowych Financial Trust

Umknęło nam, żeby o tym napisać, ale niedawno uruchomiliśmy także nową odsłonę strony http://www.financialtrust.pl/. Strona miała być lekka i elegancka, jednocześnie zaznaczając nowoczesny charakter firmy. Jesteśmy bardzo zadowoleni z efektu.

Zapraszamy do oglądania!

środa, 1 grudnia 2010

Now strona dla TUF Consulting

Nasza najnowsza kreacja dla firmy TUF Consulting jest już w sieci. Zapraszamy do oglądania: http://www.tufconsulting.pl/

Strona zbudowana w oparciu o Wordpress 3.0.1 - naprawdę wygodny CMS :)

wtorek, 30 listopada 2010

Unobtrusive validation on AJAX loaded form in ASP.NET MVC 3

I am working on a new project using the Release Candidate of ASP.NET MVC 3 and I needed to enable jQuery unobtrusive validation on an ajax loaded form. Couldn't find information on how to do this so I'm posting example code below.

A simple partial view containing the form to load can look like this:



The javascript which loades the form (only two lines are important):



And Voila! Unobtrusive client validation works perfectly.

I also needed globalization for unobtrusive validation (particularly for numbering format). If you want to know how to achieve it just comment this post and I will be glad to write about it.

poniedziałek, 22 listopada 2010

Niezawodna pomoc na orange.pl

Dzisiaj szybki wpis o tym, jaką świetną, dostosowaną do potrzeb klienta, pomoc można napotkać na orange.pl.
Wszystko wyjaśnią poniższe zrzuty z ekranu:





Mnie te artykuły bardzo pomogły - może Wam również.