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)?
how do i turn decimals from something like this, 2.23232423213, to something like this, 2.23?
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 ___@
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.