Readonly and Required on one input field

Solution 1:

Here's how i solved this problem. I tried to make a JS validator, as simple as possible.

$('#dataInput').submit(function (e) { //Form is submitted, it calls this function automatically
    var empty = 0;
    $('input[type=text]').each(function(){ //Check each input (had to be done like this, because i dont know the amount of input beforehand)
       if (this.value == "") { //The textbox is empty
           empty++;
       } 
    })
    if(empty === 0){ //No empty textboxes

    }else{
       alert(empty + ' empty input(s)'); //There are empty textboxes
   e.preventDefault(); //Prevent the submit from happening
    }

});

You can check out the fiddle here