Page 1 of 1

help me to write javscript : instant validation

Posted: Wed Sep 09, 2009 4:22 am
by om.bitsian
Hi friends
i am working on php validations. in my application 1- 10 text fields are there i.e
name, age , date etc...
I have done with all the validations but when i press the submit button and if there is a error in date field then its showing that please enter valid date. But the application is clearing all the fields and again i have to enter all the values like name, age, date etc....
can anyone help me in writing this javascript so that....when i enter wrong data at that time itself i would be able to know that there is a error in field and i can correct it out...

thank you

Re: help me to write javscript : instant validation

Posted: Wed Sep 09, 2009 10:16 am
by onion2k
om.bitsian wrote:can anyone help me in writing this javascript
You can't trust the user's content - they might have turned off javascript and submitted incorrect information - so you have to validate on the server. The only advantages of validating on the client as well is speed and saving a tiny bit of bandwidth.

Re: help me to write javscript : instant validation

Posted: Thu Sep 10, 2009 4:05 am
by om.bitsian
i think onion is right......anyway thanks shinephp for javascript.......now in php for every input
i am writing this code

<input type="text" name="username" value="<?php if(isset($_POST['SUBMIT'])) eco $_post['username']; ?>">

this code is working ...and the application is not clearing alll the fields.......
please tell me how can i show error message infront of that field and highlight with red color so that user can know that here is a error.....

i.e if i write in php page
Name : 6317432 Error : Please enter character value
Age : 24
date : 09/09/2009

thanks

Re: help me to write javscript : instant validation

Posted: Fri Sep 11, 2009 5:50 am
by om.bitsian
thanks.......its working now