Email address validation using Javascript - PHP Scripts, CSS


In forms when using email ID fields it is a good idea to use client side validation along with your programming language validation. The following example shows how you can validate an email address for a form. The script is cross browser compatibe (works for all browsers).

<script language = "Javascript">

function emailcheck(str) {

var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(at,(lat+1))!=-1){
alert("Invalid E-mail ID")
return false
}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(dot,(lat+2))==-1){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(" ")!=-1){
alert("Invalid E-mail ID")
return false
}

return true
}

function ValidateForm(){
var emailID=document.frmSample.txtEmail

if ((emailID.value==null)||(emailID.value=="")){
alert("Please Enter your Email ID")
emailID.focus()
return false
}
if (emailcheck(emailID.value)==false){
emailID.value=""
emailID.focus()
return false
}
return true
}
</script>

<form name="frmSample" method="post" action="#" onSubmit="return ValidateForm()">
<p>Enter an Email Address :<input type="text" name="txtEmail"></p>
<p><input type="submit" name="Submit" value="Submit"></p>
</form>



Tags:

How can you pass values from COBOL program to non-COBOL programs

If u want to pass values from jcl to cobol use "parm" parameter in the exec statement and in the cobol program declare the linkage section for the values to be passed.If u want to pass values from cobol to other non-cobol programs this can be done by call by reference or call by value.ex: call pgma using ws-name, ws-sex.

What is difference between oracle and sqlserver ?

Oracle:
1. Oracle runs on many platforms
2. Oracle includes IFS (Internet File System), Java integration
3. Oracle requires client install and setup (Not difficult, but very UNIX-like for Windows users)
4. Oracle is well rich with Index Options.
5. Oracle provides Materialized Views for performance improvements of Stored Data with multiple Tables.
6. Failover support in SQL is much, much easier
7.Oracle provides password complexity enforcement rule..
8.Connect with one Schema and can work with other schema.

SQl Server:
1.All DDL operations that are currently running on tables belong to database "Snapshot Isolation". "Snapshot Isolation" queries are prohibited.
2.SQL requires a complex setup of ROLLBACK Segments and Transaction Level use on it.
3.SQL has just BTREE Index while compare to Oracle.
4.SQL has limitations using Materialized Views.
5.SQL Analysis Services is included (A very powerful OLAP server)
6.SQL is ANSI-SQL '92 compliant, making it easier to convert to another ANSI compliant database, theoretically anyway (truth is every database has proprietary extensions). Oracle is generally more proprietary and their main goal is to keep their customers locked-in.

What are different types of process in jcl?

The Different Types of Process in JCL are
1. premap process
2. response process

What are the Applet's Life Cycle methods? Explain them?

* init() method - called when an applet is first loaded. This method is called only once in the entire cycle of an applet. This method usually intialize the variables to be used in the applet.
* start( ) method - called each time an applet is started.
* paint() method - called when the applet is minimized or refreshed. This method is used for drawing different strings, figures, and images on the applet window.
* stop( ) method - called when the browser moves off the applet's page.
* destroy( ) method - called when the browser is finished with the applet.

Steps for connecting to the database using JDBC

Using DriverManager: 
1. Load the Driver class using class.forName(driverclass) and class.forName() loads the driver class and passes the control to DriverManager class 
2.DriverManager.getConnection() creates the Connection to the databse 
 
Using DataSource. 
DataSource is used instead of DriverManager in Distributed Environment with the help of JNDI. 
1. Use JNDI to lookup the DataSource from Naming service server. 
2. DataSource.getConnection method will return Connection object to the database

When would you use a JDBC-ODBC Bridge?

Answer:
When ever someone wants to access microsoft oriented databases such as MS Access MS SQL server you have to use the JDBC-ODBC bridge. In general it is recommended not to use this type of bridge

What is the difference between a Driver and a DataSource (in Java JDBC)?

Driver is a software that know how to talk with actual database.while datasource is a database where data is store

What is hybernate and spring?

Hibernate offers persistence and OR(Objet-Relational) mapping for Java/J2EE applications helping them improve performance and scalability.Spring is a light-weight Java framework which paves the way to write faster applications without App Server (or EJB etc.)There are a plenty of good books on these subjects. Following the most notable amongst them:Hibernate in Action by Christian Bauer, Gavin King (Hanning)Better, Faster, Lighter Java by Justin Gehtland, Bruce A. Tate ( O'Reilly)

What is Connection Pooling?

With servlets, opening a database connection is a major bottleneck because we are creating and tearing down a new connection for every page request and the time taken to create connection will be more.Creating a connection pool is an ideal approach for a complicated servlet. With a connection pool, we can duplicate only the resources we need to duplicate rather than the entire servlet. A connection pool can also intelligently manage the size of the pool and make sure each connection remains valid. Anumber of connection pool packages are currently available. Some like DbConnectionBroker are freely available from Java Exchange Works by creating an object that dispenses connections and connection Ids on request.The ConnectionPool class maintains a Hastable, using Connection objects as keys and Boolean values as stored values. The Boolean value indicates whether a connection is in use or not. A program calls getConnection( ) method of the ConnectionPool for getting Connection object it can use; it callsreturnConnection( ) to give the connection back to the pool