Fix Validation on Name Field

liunx

Guest
Attached is a text script file w/c supposedly requies & validates 3 fields correctly..Name, Email and Telephone No.<br />
<br />
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...<br />
<br />
Can you help me change whatever is wrong with this one?<br />
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...<!--content-->Replace this function <br />
<br />
function isReady(form) {<br />
if (isEmail(form.requiredemail.value) == false) {<br />
alert("Please enter a valid email address.");<br />
form.requiredemail.focus();<br />
return false;<br />
}<br />
<br />
if (isProper(form.requiredname.value) == false || ((form.requiredname.value).split(" ")).length>1) {<br />
alert("Please enter a valid username.");<br />
form.requiredname.focus();<br />
return false;<br />
}<br />
if (isNumber(form.requiredtelephone.value) == false) {<br />
alert("Please enter a valid telephone no.");<br />
form.requiredtelephone.focus();<br />
return false;<br />
}<br />
return true;<br />
}<br />
<br />
with this one<br />
<br />
function isReady(form) {<br />
if (isEmail(form.requiredemail.value) == false) {<br />
alert("Please enter a valid email address.");<br />
form.requiredemail.focus();<br />
return false;<br />
}<br />
<br />
if (isProper(form.requiredname.value) == false || ((form.requiredname.value).split(" ")).length>1) {<br />
alert("Please enter a valid username.");<br />
form.requiredname.focus();<br />
return false;<br />
}<br />
if (isNumber(form.requiredtelephone.value) == false) {<br />
alert("Please enter a valid telephone no.");<br />
form.requiredtelephone.focus();<br />
return false;<br />
}<br />
return true;<br />
}<br />
<br />
Cheers<br />
<br />
Khalid<!--content-->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?<!--content-->Did you ever try that email validation script I provided?<!--content-->Thanks Guys!<br />
<br />
Dave,<br />
<br />
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...<br />
<br />
<br />
PeOfEo,<br />
<br />
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..<br />
<br />
Validation scripts are fun...<br />
<br />
Thanks again guys!<!--content-->
 
Back
Top