This is my HTML
<input type="text" class="date_of_birth" name="date[]" value="" onkeyup="dateOfBirth('stepbirth')">
<input type="text" class="date_of_birth" name="date[]" value="" onkeyup="dateOfBirth('stepbirth')">
Here is my javascript to collect the value for each element.
var DoB = [];
$(".date_of_birth").each(function(){
DoB.push($(this).val());
});
var newDob = DoB.slice(0,-1);
var stepVar = newDob;
It is working fine. When there are more values it sends values like this
20/02/2002,03/03/2003
which is fine.But the issue i have event on keyup on each input field. When the user fill in both fields and after if remove the data from one field then it sends values like this..
20/02/2002,
So my script stops validation here because of comma it expect the values like
20/02/2002,03/03/2003
or
20/02/2002
How can i remove comma here until input is empty.
Thanks