JS aktywacja przycisku, po wprowadzeniu danych do 2 pól

0

poniższy kod aktywuje przycisk id= submit jeżeli w pierwszej kolejności wpiszemy coś do pola o id pesel a potem do id=datwydarzenia
jeżeli robię to odwrotnie czyli pierw wydarzenia a potem pesel to przycisk się nie aktywuje
Help

<script type="text/javascript">
		/*<![CDATA[*/

		var setupCalendars = function() {
			if ((document.getElementById("datwydarzenia") != null && document.getElementById("pesel") != null)) {
				setupCalendar("datwydarzenia");

			}
		};

		var setupCalendar = function(dateField) {
			Calendar.setup({
						trigger : dateField,
						
						inputField : dateField,
						dateFormat : "%Y-%m-%d",
						onSelect : function(buttonId) {
							this.hide();
							var dateFrom = document
									.getElementById("datwydarzenia");
							var peselForm = document.getElementById("pesel");

							document.getElementById("submit").disabled = !(peselForm.value);
						}
					});
		};

		/*]]>*/
	</script>
0
var fieldsHaveValue = function(){ 
                	if(document.getElementById("pesel").value && document.getElementById("datwydarzenia").value)
                	{
                		document.getElementById("submit").disabled = false;
                	}
                	else
                	{
                		document.getElementById("submit").disabled = true;
                	}
                }
if ((document.getElementById("datwydarzenia") != null && document.getElementById("pesel") != null)) {
                setupCalendar("datwydarzenia");
                document.getElementById("pesel").addEventListener("change", fieldsHaveValue);
                document.getElementById("datwydarzenia").addEventListener("change", fieldsHaveValue);
            }
 onSelect : function(buttonId) {
                            this.hide();
                        }

1 użytkowników online, w tym zalogowanych: 0, gości: 1