JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 8th, 2010, 03:12 PM
Escape Artist Escape Artist is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 18 Escape Artist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 27 m 16 sec
Reputation Power: 0
2 number fields, dont submit form if 2nd is bigger than 1st (validation)

I have 2 fields for the user to fill in (as part of a larger form)...
Code:
<input name="total_items" type="text" class="required digits" maxlength="3" id="total_items" autocomplete="off" />
<input name="avail_items" type="text" class="required digits" maxlength="3" id="avail_items" autocomplete="off" />


i need to submit the form, but ONLY when the second value is smaller than or equal to the first value.

how can I do this? I have been trying to modify equalto from the jquery validation but no success. where do i start?

help

Reply With Quote
  #2  
Old March 9th, 2010, 02:49 AM
haydenchambers's Avatar
haydenchambers haydenchambers is offline
hack of all trades
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2009
Location: Madrid
Posts: 900 haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Week 23 h 24 m 53 sec
Reputation Power: 516
Send a message via Google Talk to haydenchambers Send a message via Skype to haydenchambers
how are you submitting at the moment ? with jq formajax plugin? with a standard submit button? with a custom ajax function? are you using validation for any other part? if so is it standard js? jq validate plugin?

and is there a chance the values will be decimals? or are they only whole numbers?
__________________
a: true is 1 and false is 0 right?
b: 1

Reply With Quote
  #3  
Old March 9th, 2010, 01:01 PM
Escape Artist Escape Artist is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 18 Escape Artist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 27 m 16 sec
Reputation Power: 0
Quote:
Originally Posted by haydenchambers
how are you submitting at the moment ? with jq formajax plugin? with a standard submit button? with a custom ajax function? are you using validation for any other part? if so is it standard js? jq validate plugin?

and is there a chance the values will be decimals? or are they only whole numbers?


standard submit button, its just a form that posts the value to a php page which deals with it (add to mysql db and return to another page)

there is validation on it using jquery validation maxlength='3', 'required', and 'digits'... and a warn message shows next to the field and prevents submission if those conditions are not met

whole numbers only.

Reply With Quote
  #4  
Old March 9th, 2010, 01:18 PM
Winters Winters is offline
Super Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jul 2003
Posts: 3,874 Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 17 h 30 m 25 sec
Reputation Power: 2569
What Hayden is asking, I think, is what have you tried so far? You are asking for help with some Javascript, so what Javascript have you used/written?
__________________
[PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

W3Fools - A W3Schools Intervention.

Last edited by Winters : March 9th, 2010 at 01:30 PM. Reason: typo

Reply With Quote
  #5  
Old March 9th, 2010, 04:11 PM
Escape Artist Escape Artist is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 18 Escape Artist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 27 m 16 sec
Reputation Power: 0
i tried to modify jquery validate...

Code:
$(document).ready(function(){
$("#addServiceForm").validate({
rules: {
avail: {
compareTo: "#total"}}});});


PHP Code:
// http://docs.jquery.com/Plugins/Validation/Methods/equalTo
compareTo: function(valueelementparam) {
return 
value >= $(param).val();
}, 

Reply With Quote
  #6  
Old March 9th, 2010, 04:54 PM
haydenchambers's Avatar
haydenchambers haydenchambers is offline
hack of all trades
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2009
Location: Madrid
Posts: 900 haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level)haydenchambers User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Week 23 h 24 m 53 sec
Reputation Power: 516
Send a message via Google Talk to haydenchambers Send a message via Skype to haydenchambers
that’s exactly where I would have gone (but basing it on the max function) .. not sure why its not working..

have you tried passing in the val straight to the max function ?
avail: {
max: $("#total").val()

Reply With Quote
  #7  
Old March 9th, 2010, 05:26 PM
Escape Artist Escape Artist is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 18 Escape Artist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 27 m 16 sec
Reputation Power: 0
Code:
$(document).ready(function(){
$("#addServiceForm").validate({
rules: {
avail: {
max: $("#total").val()}}});});


didn't work it just says "Enter a value less than or equal to " which I assume means it cant see the value in the other box

i.e. Enter a value less than or equal to {0}

even when i enter the value in 'total' before 'avail', it still cant find the value

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > 2 number fields, dont submit form if 2nd is bigger than 1st (validation)

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap