dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: Fix Validation on Name Field

Hybrid View

  1. #1
    Join Date
    Feb 2003
    Posts
    86

    Question Fix Validation on Name Field

    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...
    Attached Files Attached Files

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    2,653
    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

  3. #3
    Join Date
    Feb 2003
    Posts
    86
    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?

  4. #4
    Join Date
    Nov 2002
    Location
    Auburn, AL
    Posts
    9,222
    Did you ever try that email validation script I provided?

  5. #5
    Join Date
    Feb 2003
    Posts
    86

    Thumbs up Fixed! Finally!

    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 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!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles