Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Sponsored Links

Discuss "validation" in the JavaScript Programming forum.

JavaScript Programming - Javascript is a cross-browser client-side scripting language. Discuss Javascript and AJAX related scripts here.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1  
Old July 29th, 2008, 09:58 AM
Barn Frequenter

 
Join Date: Mar 2008
Posts: 197
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default validation

Hi,

I have 6 subject and each subject has 4 fields which the admin has fill.

Out of 6 subjects the admin has to enter data for 4 subjects

So here is the html design for it can someone tell me how my validation will be

todd

Code:
<table>
<thead>
<tr>
<th>Title</th>
<th>CourseNo</th>
<th>Course Hrs</th>
<th>Instructor</th>
<th>Room</th>
</tr>
</thead>

<tr>
<td>Maths</td>
<td><input type="text" name="courseone" id="courseone" value=""></td>
<td><input type="text" name="courseHrsone" id="courseHrsone" value=""></td>
<td><input type="text" name="Instructorone" id="Instructorone" value=""></td>
<td><input type="text" name="Roomone" id="Roomone" value=""></td>
</tr>

<tr>
<td>Science</td>
<td><input type="text" name="coursetwo" id="coursetwo" value=""></td>
<td><input type="text" name="courseHrstwo" id="courseHrstwo" value=""></td>
<td><input type="text" name="Instructortwo" id="Instructortwo" value=""></td>
<td><input type="text" name="Roomtwo" id="Roomtwo" value=""></td>
</tr>

<tr>
<td>Social Science</td>
<td><input type="text" name="coursethree" id="coursethree" value=""></td>
<td><input type="text" name="courseHrsthree" id="courseHrsthree" value=""></td>
<td><input type="text" name="Instructorthree" id="Instructorthree" value=""></td>
<td><input type="text" name="Roomthree" id="Roomthree" value=""></td>
</tr>

<tr>
<td>Arts</td>
<td><input type="text" name="coursefour" id="coursefour" value=""></td>
<td><input type="text" name="courseHrsfour" id="courseHrsfour" value=""></td>
<td><input type="text" name="Instructorfour" id="Instructorfour" value=""></td>
<td><input type="text" name="Roomfour" id="Roomfour" value=""></td>
</tr>

<tr>
<td>PT</td>
<td><input type="text" name="coursefive" id="coursefive" value=""></td>
<td><input type="text" name="courseHrsfive" id="courseHrsfive" value=""></td>
<td><input type="text" name="Instructorfive" id="Instructorfive" value=""></td>
<td><input type="text" name="Roomfive" id="Roomfive" value=""></td>
</tr>

<tr>
<td>Social Studies</td>
<td><input type="text" name="coursesix" id="coursesix" value=""></td>
<td><input type="text" name="courseHrssix" id="courseHrssix" value=""></td>
<td><input type="text" name="Instructorsix" id="Instructorsix" value=""></td>
<td><input type="text" name="Roomsix" id="Roomsix" value=""></td>
</tr>

</table>
Reply With Quote
Sponsored Links
  #2  
Old July 29th, 2008, 08:35 PM
BLaaaaaaaaaarche's Avatar
Administrator


 
Join Date: Mar 2008
Posts: 55
Thanks: 10
Thanked 7 Times in 5 Posts
Rep Power: 1
BLaaaaaaaaaarche is on a distinguished road

Awards Showcase
HTML & CSS Classic ASP 
Total Awards: 2

Default

Why are you using JavaScript to validate? Use ASP or another server side script.
__________________
"You'll never be as perfect as BLaaaaaaaaarche."
Reply With Quote
  #3  
Old July 30th, 2008, 07:24 AM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 817
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

Quote:
Originally Posted by BLaaaaaaaaaarche View Post
Why are you using JavaScript to validate? Use ASP or another server side script.
Well, typically it's a good idea to handle any validation that you can on the client-side AS WELL AS server-side.

Quote:
Originally Posted by todd2006 View Post
So here is the html design for it can someone tell me how my validation will be
I'm not going to tell you how exactly...but using JavaScript you can iterate through those fields and check if they have a value. Keep a counter and if, by the end of the iteration, there are 4 values, then the validation should pass.
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
  #4  
Old July 30th, 2008, 09:17 AM
BLaaaaaaaaaarche's Avatar
Administrator


 
Join Date: Mar 2008
Posts: 55
Thanks: 10
Thanked 7 Times in 5 Posts
Rep Power: 1
BLaaaaaaaaaarche is on a distinguished road

Awards Showcase
HTML & CSS Classic ASP 
Total Awards: 2

Default

Fine with me, but I absolutely HATE websites that have a popup that says, "You are missing a required field". After I see that, I have to click it and say, "OK", and re-enter. A-N-N-O-Y-I-N-G! I rather submit the form and have the server kick back an error message on the page. I think it is cleaner and more professional looking.
Reply With Quote
  #5  
Old July 30th, 2008, 09:22 AM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 817
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

Quote:
Originally Posted by BLaaaaaaaaaarche View Post
Fine with me, but I absolutely HATE websites that have a popup that says, "You are missing a required field". After I see that, I have to click it and say, "OK", and re-enter. A-N-N-O-Y-I-N-G! I rather submit the form and have the server kick back an error message on the page. I think it is cleaner and more professional looking.
You don't have to use a popup, just set the visibility of a div or something to display a message. I agree...the Javascript alert is annoying...which is why it's good to use a combination of div's and CSS with the JavaScript validation.
Reply With Quote
  #6  
Old July 30th, 2008, 09:23 AM
Wolffy's Avatar
Slaprentice of Wolves

 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Agreed -- but the client-side script doesn't HAVE to use a popup to indicate which fields are missing, invalid or whatever. I agree, it's much cleaner to put some kind of indication on the page near the missing field. Of course the ASP.NET validators make this kinda moot anyway.
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Bookmarks

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
date validation todd2006 JavaScript Programming 3 July 6th, 2008 11:39 AM
textbox validation todd2006 JavaScript Programming 6 July 2nd, 2008 01:30 PM
checkbox validation todd2006 JavaScript Programming 3 June 18th, 2008 07:22 PM
[ASP.Net/VB.Net] Programmatically Add Item to Validation Summary jmurrayhead Code Samples 0 March 20th, 2008 09:41 AM


All times are GMT -4. The time now is 01:25 PM.



Content Relevant URLs by vBSEO 3.2.0