Friday, November 21, 2008

Common Regular Expressions

Name

^[a-zA-Z''-'\s]{1,40}$

John Doe
O'Dell

Validates a name. Allows up to 40 uppercase and lowercase characters and a few special characters that are common to some names. You can modify this list.

Social Security Number

^\d{3}-\d{2}-\d{4}$


111-11-1111


Validates the format, type, and length of the supplied input field. The input must consist of 3 numeric characters followed by a dash, then 2 numeric characters followed by a dash, and then 4 numeric characters.

Phone Number


^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$


(425) 555-0123
425-555-0123
425 555 0123

1-425-555-0123


Validates a U.S. phone number. It must consist of 3 numeric characters, optionally enclosed in parentheses, followed by a set of 3 numeric characters and then a set of 4 numeric characters.

E-mail


^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$


someone@example.com
Validates an e-mail address.

URL


^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$


http://www.microsoft.com


Validates a URL

ZIP Code


^(\d{5}-\d{4}|\d{5}|\d{9})$|^([a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d)$

12345


Validates a U.S. ZIP Code. The code must consist of 5 or 9 numeric characters.



Password


(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$



Validates a strong password. It must be between 8 and 10 characters, contain at least one digit and one alphabetic character, and must not contain special characters.



Non- negative integer


^\d+$


0

986


Validates that the field contains an integer greater than zero.

Currency (non- negative)


^\d+(\.\d\d)?$


1.00


Validates a positive currency amount. If there is a decimal point, it requires 2 numeric characters after the decimal point. For example, 3.00 is valid but 3.1 is not.



Currency (positive or negative)


^(-)?\d+(\.\d\d)?$


1.20


Validates for a positive or negative currency amount. If there is a decimal point, it requires 2 numeric characters after the decimal point.

Sunday, November 9, 2008

ColdFusion MX 7.0.1 and 7.0.2: Hot fix available for Apache 2.2 support

ColdFusion MX 7.0.1 or 7.0.2 Server edition

1. Backup the existing cf_root/runtime/lib/wsconfig.jar
2. Download the hot fix (2.3MB).
3. Extract the new wsconfig.jar file and place it incf_root/runtime/lib.
4. Stop all ColdFusion servers and Apache 2.2. Restart

Friday, August 8, 2008

Regular Expression

* = zero or many
? = zero or one
+= one or more
"[dl]og" will match dog, or log, but it will not match dlog.
[^dl]og" now we will match any sequence ending in og that isn't preceded with a d or l, such as fog.
a range of characters using the - (dash) character

<cfform id="form1" name="form1" method="post" action="">
<cfinput type="text" name="reg" id="textfield" validate="regular_expression" pattern="([0-3]{3})([a-z]{5})*" /> </label>
<cfinput type="submit" name="button" id="button" value="Submit" />
</cfform>

Input Masking (form validation)

<cfform>
Enter Phone Number: <cfinput type="Text" name="phoneNumber" mask="(+91)(0999)(99999999)"><br>
Enter in Credit Card: <cfinput type="Text" name="CCNumber" value="" mask="9999-9999-9999-9999"><br>
<cfinput type="Submit" name="btn" value="Save">
</cfform>

Tuesday, August 5, 2008

e-Mall Project code

Application.cfm

<cfapplication name="my"
sessionmanagement="yes">

<cfif IsDefined("form.remail")>


<cfquery name="q1" datasource="emall">
select * from reg where email = "#form.remail#" and p = "#form.pass#"
</cfquery>

<cfif #form.remail# eq #q1.email#>
<cfset session.name="#q1.name#">
<cfset session.id="#q1.regID#">
<cfset session.mail="#q1.email#">
</cfif>

</cfif>


To Display Logged User Name

<cfif isDefined("session.name")> (to check variable, session exist or not)
Hi #session.name#
<cfelse>
Hi
</cfif>

To Display Picture or other items for Logged User Only

<cfif isDefined("session.name")>
<div id="apDiv34"><a href="logout.cfm">
<img src="pic/logout_icon copy.jpg" width="50" height="47" /></a></div>
</cfif>





Query Build

<cfquery name="q1" datasource="emall">
select *from dvd
</cfquery>

Add Database Values and Picture to Table

<div id="apDiv21">

<table width="113" border="1">
<tr>
<cfoutput query="q1">
<td width="103">
<a href="viewdvd.cfm?dvdID=#q1.dvdID#">
(Passing Table values to viewdvd.cfm)
<img src="#q1.pic#" width="91" height="119" />
</a>
</td>
</cfoutput>
</tr>
<tr><cfoutput query="q1">
<td>
<div align="center"><span class="style2">#q1.title#</span></div></td>
(Assign database value to table)
</cfoutput>
</tr>
</table>

<div align="center"></div>
</div>




Get Particular Table Row and URL Values

<cfquery name="q1" datasource="emall">
select *from dvd where dvdID=#URL.dvdID#
</cfquery>


To Display Selected Item Details in another page

<div id="apDiv21">

<cfoutput query="q1">
<table border="1">
<tr>
<td width="77"><div align="center"><span class="style2">FILM NAME</span></div></td>
<td width="82"><span class="style2">#q1.title#</span></td>
<td width="221" rowspan ="4">

<img src="#q1.pic#" width="200" height="240" /> </td>
</tr>
<tr>
<td height="102"><span class="style2">STARRING</span></td>
<td><span class="style2">#q1.starring#</span></td>
</tr>
<tr>
<td height="91"><span class="style2">DIRECTOR</span></td>
<td><span class="style2">#q1.director#</span></td>
</tr>
<tr>
<td><div align="center"><span class="style2">PRICE</span></div></td>
<td><span class="style2">$#q1.price#</span></td>
</tr>

</table>
</cfoutput>
</div>


To Display Add to Cart Button if Logged User exist and Product ID , User ID passes to another page for Insertion

<cfif isDefined("session.name")>
<cfform name="form1" id="form1" method="post" action="addcart.cfm?pid=#q1.dvdID#&pname=#q1.title#">
<cfinput type="submit" name="Submit" value="Add to Cart">
</cfform>
</cfif>

To User Purchased Items and User ID in Database

<cfif (isDefined ("URL.pid")AND isDefined("URL.pname"))>
(Here to checking URL.variable exist or not)

<cfquery name="q2" datasource="emall">
insert into shop (userid, username, productid, productname) values (#session.id#,'#session.name#','#URL.pid#','#URL.pname#')
</cfquery>
</cfif>

CFCALENDER

<cfform format="html" width="400" height="300">
<center>
<cfcalendar
name="calDate"
selectedDate="#dateFormat(now(), 'yyyy-mm-dd')#"
dayNames="S,M,T,W,T,F,S"
monthNames="Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"/>

<cfinput name="submit" value="Submit" type="submit" style="width:80;">
</center>
</cfform>

<cfif isDefined("form.submit")>
The date you selected was <cfoutput>#form.calDate#</cfoutput>.
</cfif>

HISTORY BACK USING JAVA SCRIPT

<a href="javascript:history.back();">Back</a>