By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,799 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,799 IT Pros & Developers. It's quick & easy.

javascript

jeremydowe
P: 10
Hi,

I am trying to write some js validation which will check between two numbers i.e.

math.random()

Min order is 6 ... don't mind if the user leaves the form box as 0

Any help here?

Jeremy.
Feb 20 '07 #1
Share this Question
Share on Google+
3 Replies

10K+
P: 13,262
Hi,

I am trying to write some js validation which will check between two numbers i.e.

math.random()

Min order is 6 ... don't mind if the user leaves the form box as 0

Any help here?

Jeremy.
Not very clear. what will be allowed and what will not be allowed. Also post any codes you have tried with.
Feb 20 '07 #2

jeremydowe
P: 10
I did try this for example:

var xval= Math.floor(Math.random()+1*5);

if (form.field.value <= xval && form.field.value > 0 ) {
alert("Minimum order of 6 is required for " + form.field_title.value);
return false;
form.field.focus();
}

I think the above example is more the oop way which in my actual code i hard coded the field.

Jez.
Feb 20 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Why are you using randomization for this? You know that it has to be minimum of 6 so just test for 5 or less (or if you're allowing floats, less than 6). Another thing is that you are returning false before giving focus to the field.
Feb 21 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.