I have adding dynamic row using Javascript in php. I need to check the validation. I am using onsubmit for validation I have got the error message when am not entering the value, if am entering the value is not post and not fetch the values also.
Example code:
<form name="myForm" method="post" action="" onsubmit="return validate();">
var row = table.insertRow(2).outerHTML="<tr id='row"+table_len+"'><td></td><td id='pickup"+table_len+"'><input type='text' id='pickup' name='pickup' onkeypress='return blockSpecialChar(event,this)' class='myTextBox1' onblur='UpperCase(this)' maxlength='8' value='' style='width:70px;text-align:left;' required></td><td> <input type='submit' class='center' style='margin-left: 8px;align:center;padding: 1px 4px;' id='submit"+table_len+"' name='submit' value='Save' class='save' > <input type='button' style='margin-left: 6px;align:center;padding: 1px 7px;' value='Cancel' class='center' onclick='cancel_row_add("+table_len+")'></td></tr><br>";
<script type="text/javascript">
function Validate()
{
if(document.getElementById('pickup').value == '')
{
alert('Please enter pickup Name');
document.getElementById('pickup').focus();
return false;
}
}
</script>