Common Validations for Web Forms

Forms are the only way through which the user and the website can interact with each other. Unusable forms can have a negative impact on the number of leads and hence the profit that can be generated from a website.

A] Error Messages:

Any error message should communicate the following as best it can:

Where the errors are: An error response should mention for which input field the error is related to. When referring to an input, traditionally use the name of that input field which will be helpful for the user to understand easily.

How an error may be fixed: If the error is simply to let the user know they missed a required field. It’s always best to communicate what the solution might be. For example,  if a telephone number can’t accept alphabetic characters, then tell the user. If a user didn’t enter the date in the correct format, show them an example of what the correct format is.

B] Form must retain previous data entries:

When submitting a form with errors, rather than having to fill out the entire form again, leave the correct data in the form. If the form can’t retain previous data entry, then the users might get frustrated and not fill the form again.

C] Don’t use alert dialog boxes for validation responses:

Here are a few reasons why:

  1. 1. When an alert box is displayed, it must first be closed before returning to the form.
  2. 2. Once closed, the only way to view the error again is to re-submit the form. This gives the user no information to refer back to.
  3. 3. When using alert boxes and pop-up windows, it is common that only the first error found is displayed, rather than a full list of errors. The form is then re-submitted by the user multiple times to discover multiple different errors.

D] Field Validation:

Email Field:

  • Valid email format aa@bb.sg / aa@bb.co.uk (and similar).
  • First character should not be a special character.
  • Special characters allowed are _ . -
  • Alphanumeric characters should be allowed.
  • For email and confirm email id fields – No copy or paste function is allowed.

Name Field:

  • First name should be mandatory.
  • Only accepts alphabets.
  • Lead and trail space should be truncated.
  • Maximum and Minimum length should be tested (Depends on requirement).

Password Field:

  • Typing value should be encrypted.
  • Minimum and Maximum length should be validated (In general Min.6 and Max.12).
  • Copy and Paste functionality should not be allowed for Password and Confirm Password field.
  • For all instance Password field should be followed by Confirm Password field.

Drop down:

  • Default text should be “-Select-” or “-Select item-”
  • Should be enabled always (depends on spec).
  • Menu items should be sorted with respect to the requirement (alphabetical order by default).

Amount/ fees field:

  • Do not allow to use comma (,) and dot (.)

Mobile or Phone Number Field:

  • Alphabets should not be allowed
  • In special characters only hyphen (-) and plus (+) signs are allowed.

Public Forms:

  • Public forms such as registration form, comment form, mail to support form, etc. should have “Captcha” to submit. To overcome Auto-bot registration and spam,  it should be used.

Date of Birth Field:

  • Should mention the format of input (mm/dd/yy or mm/dd/yyyy or dd/mm/yy  etc.)
  • If accepting the value for date, month and year in separate field, only then numerals should be allowed. Otherwise if you use single text box to get data then mention the separator allowed along with the format text. For example: mm/dd/yy or  mm-dd-yyyy

Calendar Range:

  • Should clearly explain the date format (dd/mm/yy or dd/mm/yyyy or mm/dd/yy)
  • End date should not be greater than current date.

Originally posted 2012-01-27 13:55:07.

Posted in Quality Assurance & Testing | Tagged , | Leave a comment

How to create Animated Banner in Photoshop?

We are all well aware of the importance of banners in promoting a company or its products on related websites. Animated banners if made unique and attractive, can divert a good amount of traffic to the concerned website.

Lets discuss in a short tutorial below, the step-by-step process to create animated banner in Photoshop:

1. Create a new file ‘ Ctrl+N ‘ document of the required size, then in a Layers Pallet take a new layer and make attractive background design for banner as per your requirement.
banner 1 How to create Animated Banner in Photoshop?

2. Use separate Layer for each frame, which means the content which will appear one by one in the animation should be put into individual layers.

3. In Layer Pallet there is an option available for applying effects to the texts and images used. For eg : Drop-Shadow, Outer-Glow, Bevel-Emboss, Gradient Overlay etc.
photoshop animated 2 How to create Animated Banner in Photoshop?

4. By using the above mentioned Layer Style effects, we can design attractive banners to grab attention of the users.

5. In ‘ Window ‘ menu of Photoshop, you will see the option ‘Animation‘.
Click on it, then a timeline will appear on screen which is used for preparing animations.
banner animated 3 How to create Animated Banner in Photoshop?6. In the Timeline window, a small thumbnail of the First frame will appear.
Some options are given below for making Animation:

  •  Display Time of Frame – in seconds.
  •  Once, 3 Times, Forever – To set the repeatability of animation.
  •  Play, Pause, Previous Frame, Next frame – For testing animation.
  •  Duplicate Frame – For creating next frame for animation.
  •  Delete Frame – For removing unwanted frame.
  •  Tweening Frame – For making in-between frames automatically.

photoshop animated 4 How to create Animated Banner in Photoshop?

7. Click on ‘Duplicate Frame’ to make 2nd frame for animation and thus we can make required number of frames for animation.

8. Next is to select the 2nd frame from Timeline and then click on the ‘EYE ICON‘ of the Layer which is at the top position in the Layer Pallet, by doing so the content of that layer will hide & content of the frame below will appear in the second frame of animation.
Thus the user can create multiple frames required for animation in Timeline.
banner photoshop 5 How to create Animated Banner in Photoshop?

9. We can set the Display Time of frame by using Display Time Option in timeline and test the animation by clicking on ‘Play‘ option.

10. After arranging all the frames in the timeline as per requirement, go to the ‘File’ Menu and select ‘Save for Web & Devices‘ option. A window will appear, then select ‘GIF’ file extension for prepared animation.Click on ‘Ok‘ button and save the file to the correct path.

animated banner photoshop 6 How to create Animated Banner in Photoshop?
Most often 125px by 125px size banners are used in website for advertisements.

Originally posted 2011-12-05 14:00:22.

Posted in Photoshop, Tutorial | Tagged , , , , | Leave a comment

Advantages of using PHP Frameworks

PHP is Server Side Scripting Language compatible with all known OS like Windows ,Linux etc .Nowadays, PHP frameworks are being extensively used by programmers to address to performance tuning issues faster and with ease. They offer extensible architecture and features that make source code programming easier by providing standard templates and plug-ins.Efficiency can be drastically increased using PHP Frameworks. You can choose from a plethora of frameworks tailored to satisfy your specific coding needs. Some frameworks most commonly used are Codeigniter , Zend ,Cake PHP, Smarty, etc.

The main advantages of PHP Framworks over Core PHP are as follows:

  • Frameworks Like Codeigniter, Cake PHP, Zend,  etc. support almost all database connections like  SQL, My SQL, Oracle and ODBC.
  • These superlative PHP frameworks follow MVC (Model View Controller) architecture which is a great combination of database application (model), HTML coding (view) and input/ output instructions (controller).
  • It will make your code lightweight, sharp and secure.
  • Frameworks speed up the development process by automatically creating functionality like CRUD so that the developer can focus on creativity than base structure.
  • Using frameworks drastically reduces the time of the project as complex codes need not be typed.
  • As MVC pattern is used, the code gets optomized hence will run faster.
  • These frameworks have inbuilt Core Library, hence coding gets lighter as compared to the traditional way of PHP coding.
  • Same code can be used in different projects with some modification . Hence recycling the code is one of the most important feature provided by the PHP frameworks.
  • They have several creative functions that are prepared  to have an edge in coding.
  • There are functions for handling date formats, database connections, handling emails, editing strings, etc.
  • PHP frameworks have their own specific debugging methodologies.
  • One of the most important feature is community help.  In the ever growing community you find many people ready to offer help with the frameworks and keep updated with the latest versions to enable maximum usability .

Originally posted 2011-12-14 13:55:20.

Posted in PHP | Tagged , , | Leave a comment

How to send mail with SMTP Authentication?

The Simple Mail Transfer Protocol (SMTP) is the most widely used protocol for sending electronic mail.SMTP authentication is an extension to SMTP that proves your identity to a mail gateway.

Many shared hosting providers don’t allow to use the PHP mail() function for security reasons. Using SMTP Authentication instead of mail function adds layer of security to sendmail. You have to try this class for composing and sending e-mail messages that comes with a wrapper function named smtp_mail().

SMTP server configuration details:

SmtpServer = $SmtpServer;
$this->SmtpUser = base64_encode ($SmtpUsername);
$this->SmtpPass = base64_encode ($SmtpPassword);
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->body = $body;
if ($SmtpPort == “”)
{
$this->PortSMTP = 25;
}
else
{
$this->PortSMTP = $SmtpPort;
}
}
?>

 

Features of SMTP class:

  • Supports AUTH login using TLS or SSL
  • Sends messages a plain text.
  • Validates that server is connected and logged in.
  • Validates that email message has been sent.
  • Provides additional headers if needed.
SmtpServer, $this->PortSMTP))
{
fputs ($INPUTS, “EHLO “.$HTTP_HOST.”\r\n”);
$result["hello"] = fgets ( $INPUTS, 1024 );//Request Auth Login
fputs($INPUTS, “auth login\r\n”);
$result["res"]=fgets($INPUTS,515);//Send username
fputs($INPUTS, $this->SmtpUser.”\r\n”);
$result["user"]=fgets($INPUTS,515);//Send password
fputs($INPUTS, $this->SmtpPass.”\r\n”);
$result["pass"]=fgets($INPUTS,515);//Email From
fputs ($INPUTS, “MAIL FROM: from.”>\r\n”);
$result["From"] = fgets ( $INPUTS, 515 );//Email To
fputs ($INPUTS, “RCPT TO: to.”>\r\n”);
$result["To"] = fgets ($INPUTS, 515);//Email Body
fputs($INPUTS, “DATA\r\n”);
$result["data"]=fgets($INPUTS,515 );//Send Email
fputs($INPUTS, “To: to.”>\r\nFrom: from.”>\r\nSubject:”.$this->subject.”\r\n\r\n\r\n”.$this->body.”\r\n.\r\n”);
$result["send"]=fgets($INPUTS,515);//Disconnect from SMTP
fputs ($INPUTS, “QUIT\r\n”);
fclose($INPUTS);
}
return $result;
}
}
?>

Passing parameters to SMTP class:

$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['sub'];
$body = $_POST['message'];
$SMTP = new SMTPConfig ($from, $to, $subject, $body);
$SMTP->SMTPMail();
?>

Originally posted 2011-08-27 14:39:16.

Posted in PHP, Programming | Tagged , , | Leave a comment

Basics Of Perl Special Variables

Perl is an open source, server side, high level dynamic programming language. Originally developed by Larry Wall in 1987. The basic rule of Perl is that a given task can be done in many ways. This is a very important feature perl provides for quick and efficient coding.

It can be used for the system administration as well as to prepare the web interface of that system. Also the cpan library for Perl modules is the largest in the world. No other language has such rich set of modules. Moreover like C, Java etc. Perl is also a cross platform programming language. It is by default installed on almost all the operating systems.

The reason for Perl’s popularity is because it is very powerful for text processing. Moreover it is a user friendly language as it allows users to play with their own programming patterns.

The following are the categories these variable’s are categorized into:

A. Regular Expression variables (These are read only)
B. Default variables and parameters
C. System Variables
D. File-handle or format variables
E. Error Variables
F. Input/Output Variables
G. Others

Regular Expression Variables (These are read only)

1. $’
This is a regular expression variable that holds the trailing part of the pattern match for any given pattern. If the pattern does not match then this variable holds nothing. It is a great feature as it reduces the effort to split the string to get the required sub-string. Thus, Perl does all the hard work to fetch the required substring that is made readily available in this variable.

Example:

my $string = “Incredible”  ; if($string =~ /incr/i) { print $' ; } 

Thus this will print “edible” as the output.

2. $`
This is a variable that hold the preceding part of the pattern match for any given string. This is the same as the above one with a very small difference.

Example:

my $string = “Incredible”  ; if($string =~ /edible/i) { print $` ; } 

Thus this will print “Incr” as the output.

3. $+
This variable holds the string that was last matched. It is useful when we are not sure for which of the sets of the pattern it matched.

Example:

my $string = 'IndiaAsia' ; $string =~ /(Ind) | (Aus)/ ; 

Thus $+ will hold Ind.

Originally posted 2011-11-24 14:02:46.

Posted in Perl | Tagged , , , | Leave a comment

How to write content for your website to attract more users

To make your website unique and effective for search engine optimization, sufficient amount of time should be dedicated to write its content. If you take a look at any high traffic websites, you will notice that they have quality content on them that addresses to the need of the visitors.

The following are some important practices that can be adopted to attract more users to your website:

1) There are always exceptions to every rule, but you should have a minimum of 200 to 300 words per page. Less than these may result in less keyword density which is not good for your website, more than these will cause a long list of keywords which may attract irrelevant traffic to your website.

2) Always use appropriate images to support the text which helps to break the page and enables you to minimize the keywords in HTML by naming them to images.

3) Adding, updating or altering the website content regularly helps to increase the rank of your web pages. Alteration or addition of PDF or word documents can be used for this. Make constant efforts to incorporate only the best and unique content on your website.

4) Allow the users to add content on your pages. For example, offer them a chance to review your products and services or post on your forums. These practices help your website tremendously as search engines pay a visit every time they identify new content and reward your website with higher ranking.

5) To enable the individual pages to get a higher ranking in search engines, optimize each page with appropriate keywords and a title which makes it easier for search engines to search the page.

We need to work towards achieving targeted traffic to our website which means that the visitors of the website have found the relevant information they were looking for. There are many ways to generate traffic towards your website but without a rich quality content the visitors would leave the site rather than continue viewing other pages within the same site i.e. bounce rate would be high.

Originally posted 2011-06-14 13:27:51.

Posted in Search Engine Optimization | Tagged , , , , | Leave a comment

A brief about Oracle Unified Storage

Oracle has made fantastic innovation in the field of unified data storage with hybrid storage pools and storage management tools.

A. Hybrid storage pools

This technology is combination of flash drives, HDD and Oracle’s ZFS.  ZFS adds to the performance. Flash drives gives advantages in terms of:

1. Performance:

As they provide thousands to lakhs of IOPS (Input/Output Operations Per Second).

2. Low power consumption:

As they do not have any moving parts, the power consumption is a mere fraction of what HDD actually consumes. Thus they use around 13 percent of power when they are in use and almost negligible when they are ideal.

3. Lowers costs:

Although HDD is cheaper than Flash drive but with a cost measured in IOPS, Flash Drive is a lot cheaper than HDD.

4. Higher reliability:

Flash drive has a life of around 1.85 million hours compared to 1.3 million hours for HDD.

B. Oracle Solaris ZFS

ZFS is one such technology that has reduced data management errors to a considerable extent. It uses following techniques to achieve this:

1. Virtual storage pools

Oracle uses single volume manager and more over uses a virtual file-system architecture to access physical drives. Thus this makes addition and removal of physical drives from the pool very efficient without causing any data loss. All of this is possible due to the virtual memory addressing scheme implemented in a physical environment.

2.  Data integrity

ZFS uses some new techniques to make sure the data on disk is kept secure. Here it uses COW (Copy On Write) technique, wherein the data is first written on the disk and then the pointers to the data are updated and write is committed. Also continuous data check is carried out to maintain data correctness and replace it with the mirrored one if some error occurs. This helps in faster replication of secured data and also is an efficient way to protect data against any major corruption.

3. Solid performance

All these features add to the performance of the storage. The intelligent resource pool manager immediately starts to address any new block added to the pool. Also data is evenly distributed all over the pool to sustain higher IOPS and increase throughput.

Benefits Of Oracle Unified Storage:

Oracle Unified Storage is the ideal choice for any organization looking to reduce its storage costs without compromising on performance. Ideal for running applications like:
A. Virtualization
B. Database servers
C. Cloud storage
D. Online gaming servers
E. Live Video streaming services
F. DR services
G. Applications that require large amount of computing capabilities

How to deploy Oracle Unified Storage:

Oracle takes extreme measures to deploy its technology without causing any downtime.  The storage comes with pre-installed software like  pre-configured storage pools, hardware, network with proper ports enabled and  ready to go NAS feature.
As data migration is one of the most critical and time consuming task, Oracle ZFS asks the users to set “shadow migration” for a drive. Once shadow migration is set, users can perform read/write operations on their respective drives and migration process is enabled in background with proper care to avoid data loss.

Conclusion:

Finally, I have tried to include almost all the important points that should give you a brief idea about unified storage and their benefits over traditional ones. Though you will have to do some more brainstorming to get one under your roof. There is a lot of information available on the Internet with proper comparison charts to help you find the best deal for your requirements.

Originally posted 2011-10-07 08:22:46.

Posted in Storage | Tagged , , , | Leave a comment

A brief about MongoDB

Success of any application depends on database scheme. More normalized form of database leads to faster performance of application. To design database schema with normalization is not a piece of cake. Sometimes programmers need to change code according to change in requirement which changes database schema. Hence best way to map code or documents to database is Documented Oriented Database.

Document oriented database is schema- less database. One of the most popular document oriented database is Mongo Database. Mongo database is same as relational database except that it stores data in files as documents. Documents contain data such as array, arrays contain key value pairs, value can be data such as integer, string, etc.

Why MongoDB?

Document-oriented

  • Documents (objects) map nicely to programming language data types.
  • Embedded documents and arrays reduce need for joins.
  • Dynamically typed (schema-less) for easy schema evolution.
  • No joins and no multi-document transactions for high performance and easy scalability.

High performance

  • No joins and embedding makes reads and writes fast.
  • Indexes include indexing of keys from embedded documents and arrays.
  • Optional asynchronous writes.
  • High availability.
  • Replicated servers with automatic master failover.
  • Easy scalability.
  • Automatic sharding (auto-partitioning of data across servers).
  • Reads and writes are distributed over shards.
  • No joins or multi-document transactions make distributed queries easy and fast.
  • Eventually consistent  reads can be distributed over replicated servers
  • Rich query language.

Availability of a lot of useful features like embedded docs for speed, manageability, agile development with schema-less databases, easier horizontal scalability because joins aren’t as important.

Large MongoDB deployment:

1. One or more shards, each shard holds a portion of the total data (managed automatically). Reads and writes are automatically routed to the appropriate shards. Each shard is backed by a replica set which just holds the data for that shard.

A replica set is one or more servers, each holding copies of the same data. At any given time one is primary and the rest is secondary. If the primary goes down one of the secondary takes over automatically as primary. All writes and consistent reads go to the primary, and all eventually consistent reads are distributed amongst the secondary.

2. Multiple config servers, each one holds a copy of the meta data indicating which data lives on which shard.

3. Each router may act as a server for one or more clients. Clients issue queries/updates to a router and the router routes them to the appropriate shard with the help of config servers.

4. Each client is a part of the user’s application and issues commands to a router via the mongo client library (or driver) for its language.

mongod is the server program (data or config). mongos is the router program.

mongo A brief about MongoDB

Mongo data model consists of:

  • A Mongo system (see deployment above) holds a set of databases.
  • A database holds a set of collections.
  • A collection holds a set of documents.
  • A field is a key-value pair.
  • A key is a name (string).
  • A value is a basic type like string, integer, float, timestamp, binary, a document, or an array of values.

Mongo query language:

To retrieve certain documents from a db collection, you fire a query document containing the fields that the desired documents should match. For example, {name: {first: ‘John’, last: ‘Doe’}} will match all documents in the collection with name of John Doe. Likewise, {name.last: ‘Doe’} will match all documents with last name of Doe. Also, {name.last: /^D/} will match all documents with last name starting with ‘D’ (regular expression match).

Queries will also match inside embedded arrays. For example, {keywords: ‘storage’} will match all documents with ‘storage’ in its keywords array. Likewise, {keywords: {$in: ['storage', 'DBMS']}} will match all documents with ‘storage’ or ‘DBMS’ in its keywords array.

If you have lots of documents in a collection and you want to make a query fast then build an index for that query. For example, ensureIndex({name.last: 1}) or ensureIndex({keywords: 1}). Note, indexes occupy space and slow down updates a bit, so use them only when the tradeoff is worth it.

 

Originally posted 2011-10-24 14:02:44.

Posted in Database | Tagged , , , | Leave a comment

ASP.NET Reportviewer runtime error in MVC3

In this blog post we will discuss how to integrate ASP.NET ReportViewer control in MVC3 application.

ASP.NET ReportViewer control works well in traditional Webforms (.aspx file). When I tried it in MVC 3 View (.cshtml file) it was not working.

Following is the Javascript error I encountered:

 ASP.NET Reportviewer runtime error ASP.NET Reportviewer runtime error in MVC3The error : “Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.”

Let’s discuss a workaround to run .NET report viewer in MVC3 application:

Step 1:

  • Create New Report using .NET reporting system.

Step 2:

  • Create new Webform (.aspx file)  and drag ReportViewer control from toolbox on to it.
  • Attach newly created report to this ReportViewer control.

Step 3:

  • Create new controller to show this report in MVC3 application.
  • Add view with razor engine (.cshtml file).
  • In view file add HTML <iframe> tag to show you the report.

<iframe  src=”ShowReport.aspx” width=”1000″ height=”500″ frameborder=”0″ />

  • Now run this controller to show your report in MVC3 application.

 

Originally posted 2012-02-07 10:54:31.

Posted in .NET | Tagged , , | Leave a comment

How to make TextView in android scrollable?

A TextView cannot be scrollable by default. It needs to be in a scroll view tag in the xml file in layout folder. Following code snippet will help you fix the issue:

Copy the following code snippet in your xml file in layout:

<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_height=”wrap_content” android:orientation=”vertical” android:id=”@+id/relativeLayout1″ android:layout_width=”match_parent”>

<ScrollView android:visibility=”visible” android:layout_height=”335dip” android:layout_width=”match_parent” android:keepScreenOn=”true” android:scrollbarStyle=”insideInset” android:id=”@+id/scrollView1″ android:scrollbars=”vertical” >
<TextView android:text=”The wesite text will be displayed here” android:isScrollContainer=”true” android:layout_width=”fill_parent” android:id=”@+id/pagetext” android:scrollbars=”vertical” android:layout_gravity=”top” android:keepScreenOn=”true” android:layout_height=”match_parent”></TextView>
</ScrollView>

<TableRow android:layout_alignParentLeft=”true” android:layout_height=”wrap_content” android:id=”@+id/tableRow1″ android:layout_width=”match_parent” android:layout_alignParentBottom=”true”>
<EditText android:text=”EditText” android:layout_height=”wrap_content” android:id=”@+id/editText1″ android:layout_width=”200dip”></EditText>

<Button android:text=”@string/read” android:id=”@+id/button1″ android:layout_height=”wrap_content” android:layout_width=”wrap_content” android:onClick=”myClickHandler”></Button>
</TableRow>

</RelativeLayout>

Originally posted 2011-10-27 12:48:55.

Posted in Android | Tagged , , , , | Leave a comment