/    Sign up×
Community /Pin to ProfileBookmark

coldfusion/java help?

heya, howz everyone?
Ive used some java script to validate my coldfusion form. The form that i validated looks like this … just to show u that its not a typical coldfusion form….

<table border=0 width=100%>
<tr>
<td colspan=2 bgcolor=silver><font face=’arial’ size=2>Bill To</font></td>
</tr>
<cfoutput>
<form action=”checkout_getInfo.cfm” method=”post” onSubmit=”return checkForm(this)”>

<input type=”hidden” name=”validatefields” id=”validatefields” value=” Firstname,Lastname,Phone,Fax,Email,Address1,Addres
s2,City,State,Zip”>

<input type=”hidden” name=”total” value=”#total#”>

<input type=”hidden” name=”gogo” value=”gogo”>

<cfloop list=”#dbfields#” index=”i”>
<tr>

<td><font face=”arial” size=1>#i#</font></td>

<td><input type=”text” name=”#i#” width=20></td>
</tr>
</cfloop>
</cfoutput>
</table>

And the java script that i used to validate it with is:

<html>
<head>
<title>Untitled</title>
<script language=”JavaScript”>
<!–
function checkForm(form){
fieldsToValidate = form.validatefields.value.split(“,”);
for(x=0;x<form.elements.length;x++){
for(z=0;z<fieldsToValidate.length;z++){
if(form.elements[x].name == fieldsToValidate[z]){
if(form.elements[x].value == ”){
alert(‘Please enter a value in the field ‘ + fieldsToValidate[z]);
form.elements[x].focus();
return false;
}
}
}
}
}
//–>
</script>
</head>

How could i tweek the java scrip or do somthing without cahnging the form much that would allow me to validate the form more accurately…i.e. so that in the telphone field for eample u cannot enter anything but numbers and in the expiry date (in the other form) u cannot enetr anything but date format.

ANy help would be supperb!!
Thank u soo mcuh for reading this message! Yuriy

to post a comment
Full-stack Developer

1 Comments(s)

Copy linkTweet thisAlerts:
@CharlesNov 05.2003 — [font=georgia]If I had known that you were going to cross post, I wouldn't have answered this question elsewhere.[/font]
×

Success!

Help @BabyDeveloper 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...