This project is read-only.

Jquery class not running with Xval

Apr 7, 2009 at 11:55 AM
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)) {

        // 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 === '') {
            }).focus(remove).blur(); // now change all inputs to title

            // clear the pre-defined text when form is submitted
                $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() {

    <%= Html.ValidationSummary() %>   

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

                <label for="Name">Name:</label>
                <%= Html.TextBox("Name",null,new {@test = "Text is required in here!" } ) %>
                <%= Html.ValidationMessage("Name", "*") %>
                <label for="TaxIdentificationNumber">Tax Identification Number:</label>
                <%= Html.TextBox("TaxIdentificationNumber", null, new { @test = "Text is required in here!" })%>
                <%= Html.ValidationMessage("TaxIdentificationNumber", "*")%>
                <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", "*")%>
                <label for="PayerIssuesMemberIDs">Payer Issues Member IDs:</label>
                <%= Html.CheckBox("PayerIssuesMemberIDs")%>
                <%= Html.ValidationMessage("PayerIssuesMemberIDs", "*")%>
                <input type="submit" value="Create" />

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


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 a desparate situation here :(
Apr 7, 2009 at 1: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.