I currently have some basic but working validation on a password field as below, but what I’m sure is how to check if the password contains at least 1 capital letter and at least 1 number.
This is where i am
var oldpassword = $("input[name=\"old_password\"]").val();
var newpassword = $("input[name=\"new_password\"]").val();
var confirmpassword = $("input[name=\"confirm_password\"]").val();
if (newpassword === '' || confirmpassword === '' || oldpassword === ''){
document.getElementById('buttonSubmit').style.display = 'block';
swal({
title: 'Error!',
text: 'You need to fill in all the fields',
type: 'error',
confirmButtonText: 'Return'
} )
}
I only need it on the new password bit, as the confirm password needs to match that anyway, but using the style above, just need to validate those needs.
Ye thats what I though, but I have some validation working so I thin it over writes it.
<script>
function serviceCall() {
document.getElementById('buttonSubmit').style.display = 'none';
var oldpassword = $("input[name=\"old_password\"]").val();
var newpassword = $("input[name=\"new_password\"]").val();
var confirmpassword = $("input[name=\"confirm_password\"]").val();
It would be helpful if you posted your entire form and script. As right now it is hard to see what your serviceCall function is doing and how it is being invoked.
Also, based on the way you are handling your form, you will have to use that regex in your JavaScript and not as a pattern on the field.
The reason is, you are not letting the form submit the data, you are using JavaScript to do it via an ajax call, thus the form will have little say over the matter.
Hi gandalf458, ye I know, I have discussed it with the team leader and its not their concern they said, so am carrying on until they realise it is a concern.