0

I have create a textbox:

<script>
function isNumber(field) {
    var re = /^[0-9]*$/;
    if (!re.test(field.value)) 
    {
        field.value = field.value.replace(/\D/g,"");
    }
}
</script>
<input type="text" id="1st" onkeyup="isNumber(this)"/

the script coding work fine but the problem exist while the user right click the field and paste the words.

3
Contributors
11
Replies
12
Views
6 Years
Discussion Span
Last Post by floatingDivs
0

You could add onchange, or onclick.

Done that but still cant prevent from the use of mouse. As you know: the right-click thingy

0

Onchange or onblur should do. Anyway, js safety does not exist.

As I tried, onchange or onblur is usefull when the paste is done with ctrl+v but dont work when I right click my mouse and choose paste. any idea to block the right click, or remove the "paste" option when right click?

0

You'll need to check it in php (or another server-sided language) if it's so important.

0

I saw some guide using this:

<body bgcolor="#FFFFFF" ondragstart="return false" onselectstart="return false">

but after i tried it, i don't work, why?

0

Its a script to disable selection.

My problem is that, the code don't work. i still can copy and paste using mouse

0

If I insist on using script and html? Is it really impossible to do so?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.