2012-04-24 16 views
13

hola estoy usando el complemento de validación de jquery.jquery validación, cuando el campo de entrada tiene un atributo de título, en lugar de un título de mensaje de error se da como el mensaje de error

Tengo un problema extraño, tengo una validaion como esto

jQuery("#profile_info").validate({ 

    rules : { 
     city : { 
      required : true, 
      minlength : 3, 
      maxlength : 30, 
      cityvalidation: true 
     }, 
     state : { 
      required : true, 
      minlength : 3, 
      maxlength : 30, 
      cityvalidation: true 
     } 
    }, 
    messages : { 
     city : { 
      required : " City must be filled in", 
      minlength : "At least 3 characters long", 
      maxlength : "Should not exceed 30 characters", 
     }, 
     state : { 
      required : " State must be filled in", 
      minlength : "At least 3 characters long", 
      maxlength : "Should not exceed 30 characters", 
     } 
    } 
}); 

y cityvalidation

jQuery.validator.addMethod("cityvalidation", function(value, element) { 
     return this.optional(element) || /^[a-zA-Z\u0080-\u024F\s\/\-\)\(\`\.\"\']+$/i.test(jQuery.trim(value)); 
    }, "You Have Typed Unallowed Charactors"); 

mis campos de entrada son

            <div class="select-date-container-side location-codes"> 
                 <input id="city" name="city" 
                  value="<?php if(isset($profileinfo['CityName'])){echo $profileinfo['CityName'];}else if(isset($city)){echo $city;} ?>" 
                  title="City" type="text" 
                  class="smaler-textfield textfield clear-default" 
                  tabindex="1900" /> 
                </div> 
                <div class="select-date-container-middle location-codes"> 
                 <input id="state" name="state" 
                  value="<?php if(isset($profileinfo['StateName'])){echo $profileinfo['StateName'];}else if(isset($state)){echo $state;} ?>" 
                  title="State" type="text" 
                  class="smaler-textfield textfield clear-default" 
                  tabindex="1900" /> 
                </div> 

si el cityvalidation fallidos. "You Have Typed Unallowed Charactors" mensaje, pero en lugar de eso se muestran los títulos de los campos.

enter image description here

  • Si quito el título funciona perfectamente. entonces, ¿qué supuse hacer? Quiero obtener el mensaje de error personalizado en lugar del título. por favor ayuda ........

gracias de antemano .....................

Respuesta

22

hmmm lo encontré.

i utilizarse ignoreTitle: true,

jQuery("#profile_info").validate({ 


    ignoreTitle: true, 

    rules : { 
     city : { 
      required : true, 
      minlength : 3, 
      maxlength : 30, 
      cityvalidation: true 
     }, 
     state : { 
      required : true, 
      minlength : 3, 
      maxlength : 30, 
      cityvalidation: true 
     } 
    }, 
    messages : { 
     city : { 
      required : " City must be filled in", 
      minlength : "At least 3 characters long", 
      maxlength : "Should not exceed 30 characters", 
     }, 
     state : { 
      required : " State must be filled in", 
      minlength : "At least 3 characters long", 
      maxlength : "Should not exceed 30 characters", 
     } 
    } 
}); 
Cuestiones relacionadas