<script>
jQuery(document).ready(function() {

jQuery(‚.et_pb_contact_form‘).bind(’submit‘, sendForm);

function sendForm(e) {
e.preventDefault(); // wir rufen die Funktion send_credentials auf
var myform = $(this).parents(‚form‘);
var post_data = myform.serialize();
var script = ‚http://em.hebamme-friedrichsdorf.de/wp-content/themes/DiviChild/processForm.php‘;

$.post(script, post_data, function(data) {
var resp = jQuery.parseJSON(data);
$(‚#report-success‘).html(“);
$(‚#report-error‘).html(“);
if (resp.status == „success“) {
$(‚#report-success‘).html(resp.msg);
}
else
$(‚#report-error‘).html(resp.msg);
});

}

function checkForm(e){

<!– $empfaenger = ‚‘;
$betreff = ‚Kontaktformular‘;
$nachricht = jQuery(‚#et_pb_contact_message_0‘,this).val();
$header = ‚From: ‚ . jQuery(‚#et_pb_contact_name_0‘,this).val() .'<‚.jQuery(‚#et_pb_contact_email_0′,this).val().‘>‘. „\r\n“ .
‚Reply-To: ‚ .jQuery(‚#et_pb_contact_name_0‘,this).val() .'<‚.jQuery(‚#et_pb_contact_email_0′,this).val().‘>‘. „\r\n“ .
‚X-Mailer: PHP/‘ . phpversion();
mail($empfaenger, $betreff, $nachricht, $header);
–>

var check = checkKV(jQuery(‚#et_pb_contact_name_0‘,this).val());
if (!check) {
jQuery(‚#et_pb_contact_name_0‘).addClass(‚et_contact_error‘);
jQuery(‚.et-pb-contact-message‘).append(‚<p>Ungültige Versicherungsnummer!</p>‘)
e.preventDefault();
e.stopImmediatePropagation();
}
}

function checkKV(kvnummer) {
var re = new RegExp(„^([a-z][0-9]{9})$“);
kvnummer = kvnummer.toLowerCase();
if (re.test(kvnummer)) {
var kvcode = (kvnummer.charCodeAt(0) – 96).pad(2) + kvnummer.substring(1, 9);
return checkLuhn(kvcode) == kvnummer.substring(9);
} else {
return false;
}
}

Number.prototype.pad = function(size) {
var s = String(this);
while (s.length < (size || 2)) {s = „0“ + s;}
return s;
}

function checkLuhn(code) {
if (Number.isNaN(code)) return “;
var len = code.length;
var sum = 0;
for (var i = 0 ; i < len; i++) {
var d = parseInt(code.charAt(i));
if (i % 2) { d *= 2 }
if (d > 9) { d -= 9 }
sum += d;
}
return (sum % 10).toString();
}

function checkLuhnSave(code) {
if (Number.isNaN(code)) return “;
var len = code.length;
var parity = len % 2;
var sum = 0;
for (var i = len-1; i >= 0; i–) {
var d = parseInt(code.charAt(i));
if (i % 2 == parity) { d *= 2 }
if (d > 9) { d -= 9 }
sum += d;
}
return (sum % 10).toString();
}

});
</script>