I'm using the following script for checking the nulls
in user name and password field and also checking if
the user just enterd white spaces and it is working
100%.
<script LANGUAGE="JavaScript">
<!--
function space(s) {
var cc=0;
for(var i=0; i<s.length; i++) {
var c=s.charAt(i)
if(c==' ') cc++
}
if (cc ==s.length) return false
else return true
}
function Validate(frm)
{
if (frm.userName.value=='')
{
alert("Please enter User Name.");
frm.userName.focus();
return false;
}
else if(space(frm.password.value) == false)
{
alert("Please enter password.");
frm.password.focus();
return false;
}
else
{
return true;
}
}
//-->
</script>
--- "Suresh.R" <[EMAIL PROTECTED]> wrote:
> hi,
> u may better use javascript on the client side.
>
> on formsubmit u call a method in java script
> which checks for null.however,even if he enters
> blanksspace character this
> wont work out.
> so,if u've got any minimum criteria for the username
> and password length
> check for that.
>
> if(usertextfield.value != "" && passwordfield.value
> != "") like this.
> for checking length usertextfield.value.length >=8
> something.
> this might help avoid unnecessary usage of server
> resources.
>
>
> ----- Original Message -----
> From: Crisalyn Ramos <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, February 09, 2001 4:10 PM
> Subject: Re: Querying a Database in JSP.
>
>
> > Sello,
> >
> > what is usually do is to create an SQL statement
> that goes something like:
> > "SELECT * from usertable where
> username=theEncodedUsernameHere and
> password
> > = theEncodedPasswordHere"
> >
> > Then create a ResultSet that executes the said
> statement above.
> > After that check your ResultSet if it is not null
> (this means you have an
> > existing user with the username and password that
> he encoded. this is done
> > via the statement:
> >
> > if (ResultSetObject.next()){
> >
> > file://your code here}
> > else { file://throw an error message here }
> >
> > hope this one helps..
> >
> >
> > Joy
> >
> >
> > >From: Sello Mathibe <[EMAIL PROTECTED]>
> > >Reply-To: A mailing list about Java Server Pages
> specification and
> > > reference <[EMAIL PROTECTED]>
> > >To: [EMAIL PROTECTED]
> > >Subject: Querying a Database in JSP.
> > >Date: Fri, 9 Feb 2001 12:03:13 +0200
> > >
> > > > Hi. I've created a JSP login page where I've
> got a Username field and
> a
> > > > Password field. I've created a table in my
> Access database, I've also
> > > > created a DSN and can connect to it in my
> BEAN. Now my problem is
> that:
> > >I
> > > > want to check if the user/client has entered
> some data on both fields,
> > >if
> > > > he submit before he enters some data, I want
> to through an error
> message
> > > > or alert in JavaScript. If something is
> entered on both fields, I want
> > >to
> > > > validate that data from the database through
> the bean.
> > > >
> > > > Can somebody help me cause, I'm trying to
> create a huge application,
> but
> > > > I'm stuck at the beginning!
> > > > Thank You
> > > > Oscar
> > >###########################################
> > >
> > >This message has been scanned by F-Secure
> Anti-Virus for Microsoft
> > >Exchange.
> > >For more information, connect to
> http://www.F-Secure.com/
> > >
> >
>
>===========================================================================
> > >To unsubscribe: mailto [EMAIL PROTECTED] with
> body: "signoff
> > >JSP-INTEREST".
> > >For digest: mailto [EMAIL PROTECTED] with
> body: "set JSP-INTEREST
> > >DIGEST".
> > >Some relevant FAQs on JSP/Servlets can be found
> at:
> > >
> > > http://java.sun.com/products/jsp/faq.html
> > > http://www.esperanto.org.nz/jsp/jspfaq.html
> > >
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > >
>
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
> >
>
_________________________________________________________________
> > Get your FREE download of MSN Explorer at
> http://explorer.msn.com
> >
> >
>
===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with
> body: "signoff
> JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with
> body: "set JSP-INTEREST
> DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found
> at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> >
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >
>
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with
> body: "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body:
> "set JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets