473,322 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

javascript

jeremydowe
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
3 933
r035198x
13,262 8TB
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
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
16,027 Expert Mod 8TB
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

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

Similar topics

0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.