Tags

, , , , ,


https://code.jquery.com/jquery-2.1.1.min.js 


function sendContact(id) {

if(!$("#userName_"+id).val()) {
$("#userName_"+id).focus();

alert('Enter the First Name');
valid = false;
}
return valid;
}

<?php $i=1;
while($i<5){?>
<div>
<label>Name</label>

<input type=”text” name=”userName” id=”userName_<?php echo $i; ?>” >

<input type=”submit” name=”submit” value=”submit” onClick=”sendContact(<?php echo $i; ?>);”>
<?php $i++;} ?>