Forum Moderators: open

Message Too Old, No Replies

Validations

         

jbhavin

7:07 am on Sep 8, 2003 (gmt 0)

10+ Year Member



I got to do Validations.

Q1 I want to allow user enter jus characters in a text box, how do i do that and i want validation as soon as it looses focus (onBlur?)and if error, the cursor goes back where the error was!

Q2 Also on client side, how do i validate, like i have to query with the database, to check if user exsists?

Q3 I need to allow some user to access some webpages of my document and others shld not be allowed, how do i do these?

Hope not a big thing, help me out guyzz

RonPK

11:18 am on Sep 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Lots of questions! I'll try to give some hints. I trust you can do the rest yourself :-)

Q1: check for 'characters only' by using a regular expression like
if (userInput.search(/[^a-zA-Z]/) > -1) {
// fail
}

onBlur can indeed be used to trigger a function that does the validation and on failure sets focus on the field with the non-validating input.

Q2 can't be done client-side. The only way to send form data to the server is by submitting the form.

Q3 is probably done best by providing some users a login and password. There are several server-side techniques for user authentication. An easy to implement technique is using .htpasswd and .htaccess

Hope this helps...

jbhavin

11:20 am on Sep 8, 2003 (gmt 0)

10+ Year Member



so referring my Q2, how do i do it on server side.

Also .htpass, any example, coding, i am new to this Scripting!

anyways thankx a lot