2013-10-10 3 views

답변

1

자바 스크립트를 통해 유효성을 검사 할 수 있습니다.

클라이언트 측 유효성 검사 : 이 파일을 검색하고 프로젝트에 추가

  1. jquery.validationEngine-en.js
  2. jquery.validationEngine.js
  3. validationEngine.jquery.css

그런 다음 script 태그에 페이지에 대한 참조를 추가하고 link 태그에 CSS를 추가하십시오.

하는 텍스트 상자와 class="validate[required,custom[integer]"를 사용하는 ID를 부여, 다음과 같은 스크립트를 작성 :

$(document).ready(function() { 
    $("#textboxid").validationEngine('attach', { scroll: true, promptPosition: "topLeft", showOneMessage: true, autoHideDelay: 3000, autoHidePrompt: true, delay: 500 }); 
}); 

당신이 다음의 RequiredFieldValidator에 대해 읽어 서버 측 유효성 검사를 사용합니다. 그런 다음 아래에이 기능을 참조 프로젝트에 jQuery 라이브러리를 사용하는 경우

0

가능한 정규식 링크 아래에 FUL 도움이됩니다.

jQuery.fn.forceNumeric = function() { 
return this.each(function() { 
    $(this).keydown(function (e) { 
     var key = e.which || e.keyCode; 
     if (!e.shiftKey && !e.altKey && !e.ctrlKey && key >= 48 && key <= 57 || key >= 96 && key <= 105 || key == 8 || key == 9 || key == 13 || key == 35 || key == 36 || key == 37 || key == 39 || key == 46 || key == 45) return true; 

     return false; 
     }); 
    }); 
} 

<input name="txtAny" id="txtAny" class="customonly" /> 

같은 TextBoxcssClass 속성을 지정하고 페이지의 script tags에 선 아래이 추가

$(document).ready(function() { 
    $('.customonly').forceNumeric(); 
}); 

이 모든 TextBox 내에서 이벤트 (forceNumeric)를 결합한다 그리드 템플릿 빠른 참조를 사용하여 JsFiddle Demo

관련 문제