Solved

Make sure the user does not enter or include the " " marks.

Posted on 2004-10-26
125 Views
Last Modified: 2013-12-24
I have this validation that ask to user to enter "nda" if the data is not avalable.  But I want to get an alert to the user that if the "" marks are not required.

Can you please look at my code it is not working, coz i'm just starting to learn javascript

Thanks in advance

if (Form.Authority.value == "") || (Form.Authority.lenght > 3){
     alert("Please fill in  Authority information. \nIf data is not available, please
     type "nda" without the "" marks.");
     Form.Authority.focus();
     return false;
}

Thanks
0
Question by:mdbbound
    10 Comments
     
    LVL 8

    Accepted Solution

    by:
    mdbbound, you are asking javascript questions! the javascript forum may be more appropriate. here's my answer anyway. Note: be careful with your parentheses:

    if (Form.Authority.value == "" || Form.Authority.lenght > 3 || Form.Authority.indexOf('"') > -1){
         alert("Please fill in  Authority information. \nIf data is not available, please
         type "nda" without the "" marks.");
         Form.Authority.focus();
         return false;
    }
    0
     
    LVL 35

    Assisted Solution

    by:mrichmon
    You can handle in CF.

    Don't bother the user with the fact that they have to leave out the " "
    Instead just use Replace function to remove " if they add it.

    That way the user doesn't get an error and neither does your system.
    0
     

    Author Comment

    by:mdbbound
    Hi

    Can someone please move this Q to javascript.  Thanks
    0
     

    Author Comment

    by:mdbbound
    Mrichmon,

    Thanks for your suggestion, I think that is even better just in case the javascript is turned off. I just don't know the replace function yet.  If you think this Q should go to the javascript, please move it.

    Thanks
    0
     
    LVL 17

    Assisted Solution

    by:Tacobell777
    I would not allow them to type in anything, if empty then you assume NDA, or put a checkbox next to the textfield, when ticked then consider it as NDA... What if they type in NAD or DNA ? The checks are endless, just use a checkbox, or leave empty.

    Or use regular expressions to filter your data..
    0
     
    LVL 35

    Assisted Solution

    by:mrichmon
    No since I would do the Replace server side after it is submitted.....

    Here is help:

    http://livedocs.macromedia.com/coldfusion/6/CFML_Reference/functions-pt266.htm
    0
     
    LVL 8

    Expert Comment

    by:sigmacon
    A) mdbbound, I answered your the specifc question, just wanted to let you know that you were asking JS-related questions!
    B) mrichmon is, as usual ;-), right. Form validation should be performed on the server side NO MATTER WHAT
    C) JavaScript can help improve the user experience, so it's ok to use it if you're getting paid for it
    0
     
    LVL 17

    Expert Comment

    by:Tacobell777
    I seriously think that putting one check in place for " is not good enough, just think of how many other things could be entered wrong....
    0
     
    LVL 35

    Expert Comment

    by:mrichmon
    I think that all three of the following are good suggestions/points:

    1) from sigmacon - a way to test in javascript...
    2) from myself - a way to strip out the " in CF...
    3) from Tacobell - use regular expressions or some other additional checks to catch any other situations you don't want....
    0
     

    Author Comment

    by:mdbbound
    Well,

    I actually want javascript and CF server-side.  The problem is i don't know how to do it.  I will try all the suggestions.

    Thanks, i will get back as soon as i can.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Superior storage. Superior surveillance.

    WD Purple drives are built for 24/7, always-on, high-definition security systems. With support for up to 8 hard drives and 32 cameras, WD Purple drives are optimized for surveillance.

    A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles al…
    This video discusses moving either the default database or any database to a new volume.

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now