Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
raven62 #1
Server Side validation Issue
This is a pretty straight forward question that I may be putting in a vague
way. Any help would be appreciated. I'm looking to some server side validation
on a form. I have a text field that must take a string of 10 digits all numeric
and then make sure that the entry is unique before it updates the database.
The 10 digits/numeric is done in a simple jscript and is pretty straight
forward. Actually the checking vs the database works fine as well. If the
number is uinique it updates and takes back to the main page. If the number is
not unique it goes back to the main page as well but it does not update. What I
am trying to do is have it refresh the same page if the number is not unique
and have the text next to box show up in red. Here is a basic outline of what
I have.......
Like I said , this works fine but I would like to make it refresh the same
page if the entry is not unique.
QUERY CALLED ONCE THE FORM IS SUBMITTED
<cfif IsDefined("form.submitID")>
<cfquery datasource="#Request.DSN1#" name="verifyUniqueID">
SELECT c.id
FROM customers c
WHERE assignedCustomerID = #form.assignedCustomerIDField# AND
id = #form.id#
</cfquery>
<cfif verifyUniqueID.RecordCount GT 0>
<cfset duplicateFound = 1>
<cfset URL.id = Encrypt(form.submitID, Client.linkEnc)>
<cfelse>
<cfset duplicateFound = 0>
<cfquery datasource="#Request.DSN1#">
UPDATE customers
SET assignedCustomerID = '#Trim(form.assignedCustomerIDField)#'
WHERE id = #form.id#
</cfquery>
Update Successful
</cfif>
</cfif>
BASIC FORM
<cfelseif IsDefined("URL.editId")>
<!--- <CFIF IsDefined("URL.checkUnique")> --->
<cfoutput>
<SCRIPT LANGUAGE="JavaScript">
function validateAssignedID(assignedCustomerIDField) {
var valid = "01234567899";
if (assignedCustomerIDField.length!=10) {
alert("This Field MUST be 10 digits long. Please try again.");
return false;
}
for (var i=0; i < assignedCustomerIDField.length; i++) {
temp = "" + assignedCustomerIDField.substring(i, i+1);
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters. Only numeric characters are allowed. Please
try again.");
return false;
}
}
return true;
}
// End -->
</script>
<cfquery datasource="#Request.DSN1#" name="getFolder">
SELECT folderName, companyName, assignedCustomerID
FROM Customers
WHERE id = #URL.id#
</cfquery>
<table align="center" width="750" cellpadding="0" cellspacing="0">
<form action="#CGI.Script_Name#" method="post"
name="assignedCustomerID" onSubmit="return
validateAssignedID(this.assignedCustomerIDField.va lue)">
<input type="Hidden" name="id" value="#URL.id#">
<tr>
<td colspan="3" width="750" height="16"></td>
</tr>
<tr>
<td colspan="3" width="750" id="b12">Define Assigned Custmomer
ID: #Trim(UCase(getFolder.a ssignedCustomerID))#</td>
</tr>
<tr>
<td colspan="3" width="750" height="16"></td>
</tr>
<tr>
<td width="15" height="28"></td>
<cfif IsDefined("duplicateFound") IS 1>
<span style="color: red;">ASSINGED ID:</span>
<cfelse>
<td width="100" id="b11">ASSIGNED ID:</td>
</cfif>
<td width="635"><input type="Text" name="assignedCustomerIDField"
value="#Trim(getFolder.assignedCustomerID)#" size="25" id="n11"
maxlength="25"></td>
</tr>
<tr>
<td colspan="3" width="750" height="30"></td>
</tr>
<tr>
<td colspan="3" width="750" align="center" id="n11">
<input type="Submit" name="submitID" value="SUBMIT CHANGES" id="n11"
style="width: 120px;">
<input type="Button" name="cancel" value="CANCEL" id="n11"
onClick="history.go(-1);" style="width: 120px;">
<input type="Reset" name="reset" value="RESET" id="n11" style="width:
120px;">
</td>
</tr>
</form>
</table>
</cfoutput>
<!--- </CFIF> <!--- <CFIF IsDefined("URL.checkUnique")> ---> --->
raven62 Guest
-
server-side form validation
Is there a server-side (ASP) form validation extension for DMX? Thanks, -D- -
Server-Side Validation
Hello, Does anyone have a quick and dirty script for implementing server-sider form validation (checking for illegal characters)? I already have... -
Server-side validation on Column change
Hi, How can I go about performing server-side validation when tabbing out of the column of a grid? I am trying to use a Custom Validator for... -
Server Side Validation
Does anyone know of any ASP server side form validations extensions? Thanks -
only custom validation control does server side validation?
On a CustomValidator you have to provide the validation code because otherwise it doesn't know what to do for the validation. Other validator...



Reply With Quote

