I am trying to compare value of a single text box value **"totalmarkstoall"** with multiple array of text box's **"marksscored"**, the below my java script is comparing as well on key up function.

what am unable to do is if the value of **"marksscored"** that perticuler text box is greater then the **"totalmarkstoall"** then is shows the pop up :But it should erase the value also or should not allow to enter. 

```js
function scorecompare(idval) {
    var marksscored = idval;

    var totalmarkstoall = document.getElementById("totalmarkstoall").value;
    if (parseInt(marksscored) > parseInt(totalmarkstoall))
    {
        alert("greater than Total Mrks");
    } else {

    }
}
```

```html
<input id="totalmarkstoall" type="number" style="border: 1px solid #dbdbdb;" placeholder="Enter Total Marks"></input>
<table>
    <tr>
        <td>
            <input type="text" name="marksscored[]" id="marksscored[0]" value="" onkeyup="scorecompare(this.value);"/>
        </td>
    </tr>
    <tr>
        <td>
            <input type="text" name="marksscored[]" id="marksscored[1]" value="" onkeyup="scorecompare(this.value);"/>
        </td>
    </tr>
    <tr>
        <td>
            <input type="text" name="marksscored[]" id="marksscored[2]" value="" onkeyup="scorecompare(this.value);"/>
        </td>
    </tr>
</table>
```