Current location: Hot Scripts Forums » General Web Coding » JavaScript » Validation


Validation

Reply
  #1 (permalink)  
Old 04-04-05, 12:23 AM
oracle_mik oracle_mik is offline
Newbie Coder
 
Join Date: Apr 2005
Location: Townsville
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Validation

Hi everyone,

this is my first post.. thanks for letting me in

well I need some help with form validation.. I can create inline forms ok with focused validation (ie the cursor goes to the field not filled in when the user tries to submit.. as well as an error message below the field.. at the moment I only know how to validate one field at a time)

Now what i would like to do is have a form (this is actually for a quiz..) the form sits below a flash file which shows ten images (all individually numbered) really quickly. The user has 10 fields below this and has to enter a numeric number in each field to match an image with the description.

Just like those old quizes you did in school where you had to draw a line to match the image with the name... except with this each image will be numbered and you have to enter that number into a filed matching the name/description.

So I need to create a form that cannot be successfully submitted until all of the fields are entered correctly..

I guess it would be something along the lines of inline JS validation where an error message comes up for each field not entered with the correct answer. I need all of the validation on all fields at once when the user submits.

Then they get another go to ammend their answers again and again until they get it completely right. Then the form can be submittted with the correct answers.

Can anybody help me out or point me in the direction of a tutorial that may be applicable????

Thanks very much,

Michael
__________________
<a href="http://www.oraclestudio.com.au" target="_blank">Townsville Web Design</a>
Reply With Quote
  #2 (permalink)  
Old 04-04-05, 01:27 AM
alabaster_lynch alabaster_lynch is offline
Wannabe Coder
 
Join Date: Mar 2005
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
well...let me know if I am wrong, but basically you just want to make sure that the form is completely filled in right...

well when you submit your form just have some easy little if statements to make sure that those fields are filled in for instance...let say you have a simple name, address phone number type of form. And your name text box is called 'name'...after you convert it on your action form just simple ...

if (!$name)
{
$response = 'You forgot your first name, Please go back and fill it in';
page_response($response);
exit;
}

which of course basically says if you didn't fill it out then exit...then the user is forced to back up and complete the form...

this of course is php...I don't know if asp is the same or not
Reply With Quote
  #3 (permalink)  
Old 04-04-05, 02:44 AM
oracle_mik oracle_mik is offline
Newbie Coder
 
Join Date: Apr 2005
Location: Townsville
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
not quite..

I need the form to be filled out with the correct responces in the correct fields.. i know this sounds a little weird... but this is for a quiz type form.

So for each field there is only one correct responce and that will be a numerical value (1 -10)

If the user types in the wrong number in a particular field the form will not submit... thus will happen again and again until the user fills all of the fields with the correct numbers and then can successfully submit the form.

Any wrong answers.. the form will validate an error message like JS inline validation.. however all of the fields must be validated at once on each submit try... not one after the other as this will destroy the aim of the quiz.

thanks a bunch
__________________
<a href="http://www.oraclestudio.com.au" target="_blank">Townsville Web Design</a>
Reply With Quote
  #4 (permalink)  
Old 04-04-05, 04:38 AM
alabaster_lynch alabaster_lynch is offline
Wannabe Coder
 
Join Date: Mar 2005
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
Well, it may be messy but if the quiz is short, you could always just create a simple if statement like

if ($ans1 != ans || $ans2 != ans ....){
echo ' your quiz is incorrect...please go back and try again';
exit;
}

that way if any of them are incorrect then it just tells them something is incorrect...
Reply With Quote
  #5 (permalink)  
Old 04-04-05, 07:50 PM
oracle_mik oracle_mik is offline
Newbie Coder
 
Join Date: Apr 2005
Location: Townsville
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Almost there...

thanks for helping me

I know what you are saying and it will probably be the good way to go..

Will it be possible to... when a user hits a submit button it just checks the answers and echos a 'results' line... something like you have 6 correct out of 10.

So this way the user has to keep on hitting the results button until they are all correct and then they can submit the form and send the answeres to me. This way there is no individual inline validation on particular fields.. they just get a vague return results echo on how many they currently have correct.

Thanks for your time and all your help

Michael
__________________
<a href="http://www.oraclestudio.com.au" target="_blank">Townsville Web Design</a>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation summery using Javascript aish JavaScript 2 05-15-05 08:05 AM
server side validation using php jaishalg PHP 3 03-06-05 05:55 AM
form validation puppy PHP 7 11-07-04 05:46 PM
Email Validation Broken? kvnband HotScripts Site Bug Reports 8 09-07-04 07:16 PM
type of file validation rush989 JavaScript 0 08-31-04 01:54 PM


All times are GMT -5. The time now is 10:44 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.