1

私は HTML5 フォーム検証と wana を使用してカスタム検証エラーをユーザーに変更していますが、javascript で動作する関数を見つけました。 setCustomValidity は関数ではありません。私はそれが Java スクリプト関数であることを知っています。それで、jquery で何を使用すればよいでしょうか? 同じ機能はありますか??

$(document).ready(function() {  

    //the min chars for username  

    //when field is focus out  
    $('#phone').focusout(function(){  
        //run the character number check  
            //get the phone  
     $phone = $('#phone').val();


    //use ajax to run the check  
      $.ajax({

            url: 'check.php',
             type: 'POST',
             dataType: 'html',
                data: { 
                        phone : $('#phone').val()

                        },
            success:function(response){
                if(response == "1"){

                    $('#phone').setCustomValidity('blahblahbla ');
                }
             }
                });

});

ここに私のコードがあります、あなたの答えに感謝します。

4

1 に答える 1

0

試す:

document.getElementById("phone").setCustomValidity("My Message Here");

代わりに、あなたが探しているものを達成できるかどうかはわかりません.

http://jsfiddle.net/FftM3/

于 2013-08-17T08:10:04.707 に答える