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.

You could add onchange, or onclick.

You could add onchange, or onclick.

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

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

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?

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

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?

Its a script to disable selection.

Its a script to disable selection.

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

As I said, use php.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.