Jquery class not running with Xval

Apr 7, 2009 at 10:55 AM
hi,
i recently switched to Xvalclient side validation and it is awsome..Finally found workable stuff on the net..Two thumbs up for Xval..Anyway now I have faced with some issue,
which is when I am trying to use another Jquery class with Xval client side validations..valiadations seems to not working..but my written class is working..This is my jS class---

-------------------------------------------------
jQuery.fn.hint = function(blurClass) {
    if (!blurClass) {
        blurClass = 'blur';
    }

    return this.each(function() {
        // get jQuery version of 'this'
        var $input = jQuery(this),

        // capture the rest of the variable to allow for reuse
      object = $input.attr('test'),
         $form = jQuery(this.form),
         $win = jQuery(window);

        function remove() {
            if ($input.val() === object && $input.hasClass(blurClass)) {
                $input.val('').removeClass(blurClass);
            }
        }

        // only apply logic if the element has the attribute
        if (object) {
            // on blur, set value to title attr if text is blank
            $input.blur(function() {
                if (this.value === '') {
                    $input.val(object).addClass(blurClass);
                }
            }).focus(remove).blur(); // now change all inputs to title

            // clear the pre-defined text when form is submitted
                $form.submit(remove);
                $win.unload(remove); // handles Firefox's autocomplete
        }
    });
};
-----------------------------------------

This is my asp mvc view --


<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Clearwave.Models.Payers.Payer>" %>
<%@ Import Namespace="Clearwave.Admin.Web.Controllers"%>
<%@ Import Namespace="Microsoft.Web.Mvc" %>
<%@ Import Namespace="MvcContrib" %>
<%@ Import namespace="MvcContrib.UI"%>
<%@ Import namespace="MvcContrib.UI.Html"%>
<%@ Import namespace="MvcContrib.UI.Html.Grid"%>
<%@ Import namespace="Clearwave.Models.Payers"%>
  
    

 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

  <script type="text/javascript" >

      $(function() {
       $('#Name').hint();
      $('#TaxIdentificationNumber').hint();
      $('#CharactersToRemoveFromPayerMemberId').hint();
     
  });
    </script>
       
    <h2>Create</h2>

    <%= Html.ValidationSummary() %>   

    <% using (Html.BeginForm()) {%>

        <fieldset>
            <legend>Fields</legend>
            <p>
                <label for="Name">Name:</label>
                <%= Html.TextBox("Name",null,new {@test = "Text is required in here!" } ) %>
                <%= Html.ValidationMessage("Name", "*") %>
            </p>
            <p>
                <label for="TaxIdentificationNumber">Tax Identification Number:</label>
                <%= Html.TextBox("TaxIdentificationNumber", null, new { @test = "Text is required in here!" })%>
                <%= Html.ValidationMessage("TaxIdentificationNumber", "*")%>
            </p>
            <p>
                <label for="CharactersToRemoveFromPayerMemberId">Characters To Remove From Payer Member Id:</label>
                <%= Html.TextBox("CharactersToRemoveFromPayerMemberId", null, new { @test = "Text is required in here!" })%>
                <%= Html.ValidationMessage("CharactersToRemoveFromPayerMemberId", "*")%>
            </p>
            <p>
                <label for="PayerIssuesMemberIDs">Payer Issues Member IDs:</label>
                <%= Html.CheckBox("PayerIssuesMemberIDs")%>
                <%= Html.ValidationMessage("PayerIssuesMemberIDs", "*")%>
            </p>
            <p>
                <input type="submit" value="Create" />
            </p>
            
        </fieldset>

    <% } %>
    <%= Html.ClientSideValidation<Payer>() %>
    
    <div>     
        <%=Html.ActionLink("Back to List", "Index") %>
    </div>

</asp:Content>
---------------------------------------------------


Js class does the hint in the text box when it is not on focus...which is simple displaying the "Text is required in here!" string.

Please provide me with an answer..in a desparate situation here :(
Apr 7, 2009 at 12:35 PM
hmm not sure about your hint.js code. You might want to consider using the built in callbacks in jQuery Validate for blur and focus to do your hint stuff you can easily add in some code to check an attribute on the input to create whatever effect you are looking for.

Or thinking about it perhaps the fact that there is text in the inputs is casuing a false positive on the jQuery Validate front.

Mark