jQuery 1.7+を使用してからonを使用する場合は、動的に作成された入力を委任する必要があります
$(document).on('blur','#encdomlocal input:nth-child(2)',function() {
それ以外の場合は、デリゲートjquery 1.6以下を使用できます
$(document).delegate('#encdomlocal input:nth-child(2)','blur',function() {
document
任意の親要素に置き換えることができます
アップデート:
if (REGEX.test($(this).val())) { //<-- I don't know what you were testing but using $(this) works here
$(this).removeClass();
$(this).addClass("good");
}
else {
$(this).removeClass();
$(this).addClass("bad");
}
更新されたフィドルは次のとおりです http://jsfiddle.net/9DW8f/9/
使っていた
if (REGEX.test($("#encdomlocal input:nth-child(2)").val()))
blur
一連の要素を返していたので、イベントを発生させた現在のテキストボックスをテストしていませんでした
jQuery オブジェクト: ラップされたセット: セレクターは、「ラップされたセット」と呼ばれる jQuery オブジェクトを返します。これは、選択されたすべての DOM 要素を含む配列のような構造です。ラップされたセットを配列のように反復処理したり、インデクサー ($(sel)[0] など) を介して個々の要素にアクセスしたりできます。さらに重要なことに、選択したすべての要素に対して jQuery 関数を適用することもできます。
同じ REGEX を使用する場合は、コンマで区切って他のセレクターを追加できます
$("#encdomlocal").on("blur", "input:nth-child(2),otherSelector",//<--- use this if regex for validation is the same
新しい正規表現を使用している場合は、単に使用できます
$(document).on('blur','otherSelector',function() {
// validation code goes here. You can pretty much copy the other one and change the regex to what you need
});