Copy link to clipboard
Copied
I have been trying to validate a few fields before submitting a form. Once the fields are validated by CF I want to pop up a sign in form if the user is not signed in. However, the problem is that the sign in form is pop up without validation.
inquiry.cfm
<cfif not isdefined("form.p1")>
<cfform name="inquire" action="inquiry.cfm" method="post">
<input type="hidden" name="p1" value="1">
<cfinput type="text" name="email" size="50" maxlength="50" required="yes" autofocus="on" validate="email">
<cfinput type="text" name="subject" size="50" maxlength="50" required="yes" validate="noblanks">
<cftextarea name="message" cols="45" rows="8" wrap="soft" required="yes" validate="noblanks"></cftextarea>
<cfif signedin>
<input type="submit" value=" Send ">
<cfelse>
<input type="submit" value=" Send " onclick="signin(); return false">
</cfif>
<cfelse>
do stuff....
</cfif>
The "signin" function will pop up the sign in form.
What I have tried so far besides the above:
Any help is appreciated. Thanks in advance.
Copy link to clipboard
Copied
You could improve the design immensely. The usual steps in applications that use sign-in are as follows.
Enable session management. The ColdFusion application will then keep track of individual visitors.
When a user visits, anywhere in the application, check if he is signed in. If not, send him to sign-in page. The sign-in page, say, signin.cfm, is on the server. It consists of ColdFusion code, not Javascript.
Copy link to clipboard
Copied
The problem is only certain function requires login. So I am stuck.
Copy link to clipboard
Copied
You could still follow the above steps, restricting the implementation only to the part that requires login. For example, you could restrict the functionality to a given directory, giving it its own Application.cfc file.