[jQuery] Re: validating dynamically generated data

2008-05-07 Thread Jörn Zaefferer

You need to run that validation on submit, too. If you don't need
remote validation, you can still use the validation plugin and
implement the logic you have as a custom method:
http://docs.jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage

Jörn

On Wed, May 7, 2008 at 8:07 PM, jpl80 <[EMAIL PROTECTED]> wrote:
>
>
>  I figured it out... mostly:
>
> $(document).ready(function() {
> $("div.instock input.order-qty").keyup(function(){
> var x = parseInt($(this).val());
> var y = 
> parseInt($(this).siblings("span.qty").attr("title"));
> if (x > y) {
> $(this).siblings("span.error").text("Not 
> enough in stock");
> } else {
> $(this).siblings("span.error").text("");
> }
> });
>
> });
>
>  however, it still allows the user to submit the form. How do I stop them
>  from being able to submit the for if the quantity they ordered is over the
>  limit?
>
>  --
>  View this message in context: 
> http://www.nabble.com/validating-dynamically-generated-data-tp17091060s27240p17111078.html
>
>
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.
>
>


[jQuery] Re: validating dynamically generated data

2008-05-07 Thread jpl80


I figured it out... mostly:

$(document).ready(function() {
$("div.instock input.order-qty").keyup(function(){
var x = parseInt($(this).val());
var y = 
parseInt($(this).siblings("span.qty").attr("title"));
if (x > y) {
$(this).siblings("span.error").text("Not enough 
in stock"); 
} else {
$(this).siblings("span.error").text("");

}
});

});

however, it still allows the user to submit the form. How do I stop them
from being able to submit the for if the quantity they ordered is over the
limit?

-- 
View this message in context: 
http://www.nabble.com/validating-dynamically-generated-data-tp17091060s27240p17111078.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: validating dynamically generated data

2008-05-07 Thread jpl80




pedalpete wrote:
> 
> 
> Have you checked out the validate plugin?
> http://plugins.jquery.com/project/validate
> 
> Their is a method they have where you can actually run an ajax call to
> your server to check for a valid input, or you could use it with your
> statically set value as you have already done.
> 
> 

I've looked at that. But data I need to compare is right there on the page!
All I want to do is say:

On keyup () {
  var x = getCurrentValue(input);
  var y = getCurrentValue("div.qty");
  if (x > y) {
error("not enough in stock");
  }
}
-- 
View this message in context: 
http://www.nabble.com/validating-dynamically-generated-data-tp17091060s27240p17104102.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: validating dynamically generated data

2008-05-06 Thread pedalpete

Have you checked out the validate plugin?
http://plugins.jquery.com/project/validate

Their is a method they have where you can actually run an ajax call to
your server to check for a valid input, or you could use it with your
statically set value as you have already done.



On May 6, 1:01 pm, jpl80 <[EMAIL PROTECTED]> wrote:
> I need to validate some dynamically generated form data to ensure clients
> can't order more of something than we have in stock. I can't set static
> comparisons. Here is my html:
>
> 
> 
>
> 
>   manual 1
>   90
>for="150">Qty:
> 
>
> 
>   manual 2
>   48
>for="151">Qty:
> 
>
> 
>
> I want to validate on keyup(). In rough pseudocode, something like this:
>
> $(document).keyup(function(event){
>   if (($this.getValue(input)) > ($this.getValue(span.qty))) {
> addText("Not enough in stock");
>   }
>
> });
>
> I know that's not even close. Could someone help me?
> --
> View this message in 
> context:http://www.nabble.com/validating-dynamically-generated-data-tp1709106...
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.