Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable input in html

I'm creating the 8 puzzle box game in Javascript and Jquery mobile. I've done the boxes with an <input readonly></input> and I've putted all of them in a 9x9 table. The problem is that when I click on a box to move it,even if it is readonly, the mobile device try to write in it and shows the keyboard. This is not what I want...I want to disable the input or use something different from <input>. I tried with disable="disabled" but still doesn't work. This is the code:

<form name="box">
    </center>
    <table align="center">
        <tr>
            <td ><input name="casella1" value="8" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
            <td ><input name="casella2" value="5" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
            <td ><input name="casella3" value="2" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
        </tr>
        <tr>
            <td ><input name="casella4" value="6" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
            <td ><input name="casella5" value="3" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
            <td ><input name="casella6" value="4" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
        </tr>
        <tr>
            <td ><input name="casella7" value="1" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
            <td ><input name="casella8" value="7" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>
            <td ><input name="casella9" value="" onClick="test(this.value)" readonly style="text-align: center; width:50px; height:50px; font-weight:bold; background-color: #C0C0C0; border-style: solid; border-color: black"></td>

        </tr>
    </table>
    </form>    
like image 561
Malo Avatar asked Dec 03 '22 00:12

Malo


1 Answers

You should use disabled="disabled" instead of disable="disable" !

like image 168
Val Avatar answered Dec 05 '22 13:12

Val