This how i validate my required characters and the length
JavaScript
- function submitChangej(){
-
-
var inputlastName = document.getElementById("lastname");
-
var inputfirstName = document.getElementById("firstname");
-
var inputmobileNumber = document.getElementById("mobilenumber");
-
var inputidNumber = document.getElementById("idnumber");
-
var firstname = /^[a-zA-Z-\s]{2,128}$/;
-
var lastname = /^[a-zA-Z-\s]{2,128}$/;
-
var mobilenumber = /^[0-9]{10,20}$/;
-
var idnumber = /^([0-9]){2}([0-1][0-9])([0-3][0-9])([0-9]){4}([0-1])([0-9]){2}?$/;
-
-
-
var inputSubmit = document.getElementById("applyforreseller");
-
-
var Container = document.getElementById('Agreement');
-
-
if((inputfirstName.value.length < 2 || inputfirstName.value.length > 128 ) || ( inputlastName.value.length < 2 || inputlastName > 128 ) || (inputmobileNumber.value.length < 10 || inputmobileNumber > 20) || (inputidNumber.value.length < 13)){
-
-
-
Container.style.display = 'none';
-
}
-
else{
-
-
Container.style.display = 'block';
-
}
-
var Container = document.getElementById('Agreement');
-
if((firstname.value.match(firstname) != null) || (lastname.match(lastname) != null) || (mobilenumber.value.match(mobilenumber) != null) || (idnumber.value.value.match(idnumber) != null)){
-
-
Container.style.display = 'none';
-
}
-
else{
-
-
Container.style.display = 'block';
-
-
}
-
}
-
I want to hide the button if value does not match the required type, I m able to hide it on the length, but my match does not work.
I than call my method
on the fields that i validate.
The button should be hidden when match and length are invalid, if everything is correct than the button should appear.
Your will be appreciated