开发者

On propertychange issues with text value

I have an application like that I put an alert code so when I insert in machine 1 dollar the value="" changes to 1 so text input shows number I tried to make alert on propertychange I mean: when text value its > = 1 then shows alert telling that value changed to 1 or 2 3开发者_如何学运维 4 but now its show me alert when its 0 and 1 too I only want > = 1 what I'm doing wrong?

Basically, I want to show alert when value changes to a number bigger or equal to 1

here is javascript:

 <script type="text/javascript">
    function Init () {
        var textarea = document.getElementById ("textarea");
        if (textarea.addEventListener) {    // Firefox, Opera, Google Chrome and Safari
            textarea.addEventListener ('textInput', OnTextInput, false);    // Google Chrome and Safari
        }
    }

        // Google Chrome and Safari
    function OnTextInput (event) {
        alert ("The following text has been entered: " + event.data);
    }
        // Firefox, Google Chrome, Opera, Safari from version 5
    function OnInput (event) {
        alert ("The new content: " + event.target.value);
    }
        // Internet Explorer
    function OnPropChanged () {
        if (event.propertyName.toLowerCase () == "value>==1") {
            alert ("NEW VALUE ON TOTAL FIELD: " + event.srcElement.value);
        }
    }

</script>

and html of form:

<td width="150" height="100"><input type="text" name="getAmount" style="width:300px; height:80; text-align: left;" class="last_inp" value="" onpropertychange="$('advert_1').css('display', 'none'); OnPropChanged ();"></td>

thanks in advance


My I introduce you to jQuery?

   <input type="text" id="amount" />

   <script type="text/javascript">
    $(document).ready(function () {
        $('#amount').change(function () {
            var value = $(this).val();

            if (value >= 1) {
                alert("NEW VALUE ON TOTAL FIELD: " + value);
            }
        });
    });
    </script>

Some additional reading material: http://api.jquery.com/change/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜