Can anyone provide assistance with this? I've been struggling for some time now.
I am in need of a JavaScript code that can compare two fields in a contact form to ensure they match. For example, Phone Number and Phone Number Again. Both fields must match.
I am using the Fast Secure Contact Form plugin in WordPress and trying to input this JavaScript code into the necessary field, but it's not working as expected.
The current names of the fields are:
Need field3_4 to match field3_5
field3_4 is labeled phone> field3_4 is called phone again
<script type="text/javascript">
function isNumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
}
function validateMe()
{
var phone = document.getElementById('field3_4').value;
var phone_again = document.getElementById('field3_5').value;
if(phone!=phone_again)
{
alert("Numbers do not match in both fields");
return false;
}
else
{
alert("Great! They match correctly!!");
}
}
</script>