How can I modify the script below so that it alerts not only when the field is empty, but when the field is empty or contains less than 10 digits (it can contain anything, not only digits)?
if (myform.mytextinput.value=="")
alert ('Please enter something!");
A good script that checks for ten digits is this:
var input_dg = document.getElementById("mytextinput");
var text_dg = input_dg.value;
var totalNrOfDigits = 0;
for(var i = 0; i < text_dg.length; i++){
if(/\d/.test(text_dg[i])){
totalNrOfDigits++;
}
}
alert ('Please enter at least 10 digits!');
I just need to "paste" the second script in the first, but I lack the know-how. Both scripts are inside a large form validation script...