/    Sign up×
Community /Pin to ProfileBookmark

customer fill-out form help(!!!)

hey, hey
what’s up everyone?

i’m new to the world of javascript and i’ve encountered some problems while working on a customer fill-out form.

i’m hoping someone here could help me out… please…

here are my questions:

  • 1.

    how do i connect a .js file (containing javaScript functions) to an html file that uses it’s functions (a css file also needs to be connected to the same html files)?

  • 2.

    how do i turn decimals from something like this, 2.23232423213, to something like this, 2.23?

  • 3.

    i need to check that certain field within the customer form are filled in in a certain way… to me, the expressions i’ve used seem like they should work, but my computer disagrees. can anyone give me some suggestions on what i’m doing worng, or if i’m right on any of these?

  • Last Name –> STIPULATION: only letters

    function checkLname(f)
    {
    var name= f.lname.value;
    var expr= /^[A-Z a-z] ?/;
    var pos= name.search(expr);

    if(pos!=0)
    {
    alert(“You must enter a valid Last Name”);
    f.lname.focus();
    return false;

    }else{
    return true;
    }
    }

    Frist Name –> STIPULATION: only letters

    function checkFname(f)
    {
    var fname= f.fname.value;
    var expr= /^[A-Z a-z] ?/;
    var pos= fname.search(expr);

    if(pos!=0)
    {
    alert(“You must enter a valid First Name”);
    f.fname.focus();
    return false;

    }else{
    return true;
    }
    }

    Number, Streen Name –> STIPULATION: 123, Main Street

    function checkStNo(f)
    {
    var address= f.address.value;
    var expr= /^d+, ?[A-Z a-z]+ ?[A-Z a-z]* ?/;
    var pos= address.search(expr);

    if(pos!=0)
    {
    alert(“You must enter a valid Street Number and Street Name”);
    f.address.focus();
    return false;

    }else{
    return true;
    }
    }

    Telephone –> STIPULATION: (123)-456-7890

    function checkPhone(f)
    {
    var phone= f.phone.value;
    var expr= /^1d{3}2-d{3}-d{4}$/
    var pos= phone.search(expr);

    if(pos!=0)
    {
    alert(“You must enter a valid Phone Number”);
    f.phone.focus();
    return false;

    }else{
    return true;
    }
    }

    E-mail –> STIPULATION: ______@_______.com and/or ______@_______.ca

    function checkEmail(f)
    {
    var email= f.email.value;
    var expr= var expr= /^w+@w+.com$/;
    var pos= email.search(expr);

    if(pos!=0)
    {
    alert(“You must enter a valid E-mail Address”);
    f.email.focus();
    return false;

    }else{
    return true;
    }
    }

    Credit Card –> STIPULATION: 5500000000000004 or 4111111111111111 only
    ???
    any ideas?

    thank you in advance.

    to post a comment
    JavaScript

    7 Comments(s)

    Copy linkTweet thisAlerts:
    @96turnerriNov 08.2003 — 1)

    <script language="javascript" src="JS/log.js"></script>

    <a href="javascript:function()">Click Here</a>

    2) [URL]http://javascriptsource.com[/URL] look for rounding textboxes
    Copy linkTweet thisAlerts:
    @zachzachNov 08.2003 — answers for...

    1.)
    <i>
    </i>&lt;script src="the path/thefile.js"&gt;dont put anything here&lt;/script&gt;

    ===========================

    2.)

    lets pretent the variable A1=2.23232423213...
    <i>
    </i>A1=2.23232423213
    A2=A1.toString()
    A3=A2.substring(0, 4)

    so now if you did...
    <i>
    </i>document.write(A3)

    you would get...

    2.23
    ===========================


    3.)for first and last name:
    <i>
    </i>


    function checkLname(f) {
    var expr= "a"||"b"||"c"||"d"||"e"||"f"||"g"||"h"||"i"||"j"||"k"||"l"||"m"||"n"||"o"||"p"||"q"||"r"||"s"||"t"||"u"||"v"||"w"||"x"||"y"||"z"
    var name= f.lname.value; //or f.fname.value;
    var name2 = name.toLowerCase()
    var pos= name2.indexOf(expr)

    if(pos!=0) {
    alert("You must enter a valid Last Name");
    f.lname.focus(); //or f.fname.focus();
    return false;
    }else{
    return true;
    }
    }

    for address:
    <i>
    </i>var expr2= "A"||"B"||"C"||"D"||E"||F"||G"||"H"||"I"||"J"||"K"||"L"||"M"||"N"||"O"||"P"||"Q"||"R"||"S"||"T"||"U"||"V"||"W||"X"||"Y"||"Z"||"a"||"b"||"c"||"d"||"e"||"f"||"g"||"h"||"i"||"j"||"k"||"l"||"m"||"n"||"o"||"p"||"q"||"r"||"s"||"t"||"u"||"v"||"w"||"x"||"y"||"z"||1||2||3||4||5||6||7||8||9||"1"||"2"||"3"||"4"||"5"||"6"||"7"||"8"||"9"||","

    function checkLname(f) {
    var name= f.address.value;
    var name2=name.toString()
    var name3=name2

    var ma = 0

    for(i=0;i&lt;name3.length;i++) {
    ss = name3.substring(i, i+1)
    if(ss == expr2) {
    var ma = ma+0
    }
    if(ss != expr2) {
    var ma = ma+1
    }
    }


    if(m!=0) {
    alert("You must enter a valid Street number");
    f.lname.focus();
    return false;
    }else{
    return true;
    }
    }

    for phone number:
    <i>
    </i>var expr2= 1||2||3||4||5||6||7||8||9||"1"||"2"||"3"||"4"||"5"||"6"||"7"||"8"||"9"||"-"

    function checkLname(f) {
    var name= f.whatever.value;
    var name2=name.toString()

    var ma = 0

    for(i=0;i&lt;name2.length;i++) {
    ss = name2.substring(i, i+1)
    if(ss == expr2) {
    var ma = ma+0
    }
    if(ss != expr2) {
    var ma = ma+1
    }
    }


    if(m!=0) {
    alert("You must enter a valid Street number");
    f.whatever.focus();
    return false;
    }else{
    return true;
    }
    }


    ===========================

    there you go that should work(make sure you fix the text boxes names in the script, sorry I forgot to do that 2 lazy!lol)

    -zachzach
    Copy linkTweet thisAlerts:
    @zachzachNov 08.2003 — acually, for 96turnerri's link, use:

    <a href="javascript:thefunctionname('a param', 'anotherparam')">Click here</a>
    Copy linkTweet thisAlerts:
    @96turnerriNov 08.2003 — hehee glad you used my method for some thought what you posted you were dismissing mine lol?
    Copy linkTweet thisAlerts:
    @zachzachNov 08.2003 — lol, its just that "java script:" is not a valid system port(like a:/, c:/, vbscript:, aim:, ect), but "javascript:" is the correct way lol
    Copy linkTweet thisAlerts:
    @MASTERofPUPPETSauthorNov 08.2003 — thanks to all who've contributed...

    points 1) and 2) have been resolved, but point 3) i still have some questions about:

    istead of using this kind of code [B]var expr= "a"||"b"||"c"||"d"||"e"||"f"||"g"||"h"||"i"||"j"||"k"||"l"||"m"||"n"||"o"||"p"||"q"||"r"||"s"||"t"||"u"||"v"||"w"||"x"||"y"||"z"[/B] is there any way to check the text fields using Metacharacters and Metasymbols?
    Copy linkTweet thisAlerts:
    @zachzachNov 08.2003 — probably, but i dont know of them sorry.Ask pyro he probably knows some
    ×

    Success!

    Help @MASTERofPUPPETS spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.1,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,
    )...