Click to See Complete Forum and Search --> : Fix Validation on Name Field
Four_of_Five
02-23-2003, 03:18 PM
Attached is a text script file w/c supposedly requies & validates 3 fields correctly..Name, Email and Telephone No.
At first i thought I finally got it to work...until i...well, tried putting in a long complete name...ex. Richard S. Small :) on the Name Field...it prompts an invalid username...apparently when you put in a name that breaks into more than two spaces it doesnt accept it...
Can you help me change whatever is wrong with this one?
Also, I think there's something that needs to be "improved" on the way I "validate" my Telephone field...and i think it "lacks" something at the end...
khalidali63
02-23-2003, 04:09 PM
Replace this function
function isReady(form) {
if (isEmail(form.requiredemail.value) == false) {
alert("Please enter a valid email address.");
form.requiredemail.focus();
return false;
}
if (isProper(form.requiredname.value) == false || ((form.requiredname.value).split(" ")).length>1) {
alert("Please enter a valid username.");
form.requiredname.focus();
return false;
}
if (isNumber(form.requiredtelephone.value) == false) {
alert("Please enter a valid telephone no.");
form.requiredtelephone.focus();
return false;
}
return true;
}
with this one
function isReady(form) {
if (isEmail(form.requiredemail.value) == false) {
alert("Please enter a valid email address.");
form.requiredemail.focus();
return false;
}
if (isProper(form.requiredname.value) == false || ((form.requiredname.value).split(" ")).length>1) {
alert("Please enter a valid username.");
form.requiredname.focus();
return false;
}
if (isNumber(form.requiredtelephone.value) == false) {
alert("Please enter a valid telephone no.");
form.requiredtelephone.focus();
return false;
}
return true;
}
Cheers
Khalid
Four_of_Five
02-24-2003, 11:44 AM
Thanks! I haven't actually..."applied & tested" it yet...but just out of curiosity...what were the changes that were made and why...what caused the error?
PeOfEo
02-24-2003, 08:46 PM
Did you ever try that email validation script I provided?
Four_of_Five
02-25-2003, 12:31 PM
Thanks Guys!
Dave,
Your last post did the trick! :) I think i"ll try your Tel.number scheme too...moving forward, I think my "next" dilemma would be how to keep the fields (esp. the numbers fields) from being "under- fulfilled"...you know...like they have to put in "at least" 10digits/characters to make it a "valid field"...i also found out that because "-" and "()" are accepted as is...visitors can just type these instead of numbers...and still the field will validate it...
PeOfEo,
Hmmm...w/c one:confused: sorry man, i got at least a dozen of them floating around my pc...i sort of mixed them up whichever gets to work with the least & easiest modifications, i use immediately.... until i "break" them up..I think this one is the most "fixed" of the lot though..
Validation scripts are fun...
Thanks again guys!