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

Validation Question

P: n/a

I have an application that uses token values in HTML. The token values
either feed or display data from a database linked with an ISAPI
application. I have reached a point where I need to evaluate what the
user enters into a quantity ordered field and compare it with the
minimum quantity field. I created a variable for my min qty field:
Var MinQty = ~~ML_UDF_MinQtyToken$~~;

The quantity entry box is set up like this:

<td class="psdata" valign="top" align="left"><nobr><input
type="~~mi_qty_fld$~~" name="~~row_quantity_name$~~"
value="~~quantity$~~" size="4" maxlength="10" class="formentry">
&nbsp;</nobr></td>

How would I evaluate the value entered in the quantity box so its
always grater than the min qty value? I would like to throw up a message
box for the user when min qty is violated. Help appreciated. Thanks.
Frank

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Frank Py wrote:
Var MinQty = ~~ML_UDF_MinQtyToken$~~; ^^^ ^^^^^^ ^ ^
[1] [2] [3] [3]

[1] The keyword is `var'. JavaScript is case-sensitive.

[2] Identifiers starting with uppercase letters should
be reserved for constructor function identifiers
to avoid confusion. Instead, the first character
of the identifier should be used as a prefix to
indicate which type is expected.

[3] You need to use straight single or double quotes as
JavaScript string delimiters, not graphic ones. (Use
a plain text editor, *not* a word processor.)
And MinQty is a number, is it not? So its value
should not be quoted at all, being a numeric literal.
The quantity entry box is set up like this:

<td class="psdata" valign="top" align="left"><nobr><input
type="~~mi_qty_fld$~~" name="~~row_quantity_name$~~"
value="~~quantity$~~" size="4" maxlength="10" class="formentry">
&nbsp;</nobr></td>
You know that this is invalid HTML, so it can only be the server-side
code to be replaced before served, not what the user agent gets.
How would I evaluate the value entered in the quantity box so its
always grater than the min qty value? I would like to throw up a
message box for the user when min qty is violated.


Now we are talking about client-side scripting, so you should have
posted what the client (user agent) gets. You have not, so here is
only *my* quick-hacked example which also avoids global variables:

function checkValue(o)
{
var sMinQty = o.form.elements['qty_min'].value;
if (+o.value < +sMinQty)
{
if (typeof prompt == "function" || typeof prompt == "object")
{
while (+o.value < +sMinQty)
{
o.value =
prompt(
"Below minimum quantity (" + sMinQty + ")."
+ " Type new value, or cancel to use the minimum.")
|| sMinQty;
}
}

if (typeof o.focus == "function" || typeof o.focus == "object")
o.focus();

return false;
}
return true;
}

<form action="foobar">
<input type="hidden" name="qty_min" value="42">
<input name="qty" onchange="checkValue(this);">
<input type="submit">
</form>

You could test for valid values on submit as well, and you have to do
it always server-side since client-side scripting can be restricted,
disabled or not even supported.

<form
action="foobar"
onsubmit="return checkValue(this.elements['qty']);">
<input type="hidden" name="qty_min" value="42">
<input name="qty">
<input type="submit">
</form>
HTH

PointedEars
Jul 20 '05 #2

P: n/a
Thomas 'PointedEars' Lahn <Po*********@web.de> writes:

....
Instead, the first character of the identifier should be used as a
prefix to indicate which type is expected.


That is a matter of opinion, where I happen to hold a different one.

While you *can* use the variable name to suggest the type of values
you intent to let it refer to, I find that a good, descriptive name
is sufficient. It is the only naming method that can be shown to
other readers without further explanation.

Otherwise I agree.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

P: n/a
Hi,

Lasse Reichstein Nielsen wrote:
Thomas 'PointedEars' Lahn <Po*********@web.de> writes:

...
Instead, the first character of the identifier should be used as a
prefix to indicate which type is expected.

That is a matter of opinion, where I happen to hold a different one.

While you *can* use the variable name to suggest the type of values
you intent to let it refer to, I find that a good, descriptive name
is sufficient. It is the only naming method that can be shown to
other readers without further explanation.

Otherwise I agree.
/L


While I personally favour the Ungarish notation for identifiers (if only
because it helps to find a variable faster when you use an Intellisense
IDE like Visual Studio.NET), it should be noted that Microsoft
recommends abandoning the Ungarish notation. The reasons given is:
1) It makes the code language dependant, because not every language has
the same type (or at least not the same type names). I think that this
can be overcome by simply standardizing the prefixes for the set of
languages one uses.
2) It makes maintaining the code more difficult, because if you change
the type of an identifier while developing or maintaining the code, you
must also change the identifier name. I don't think it's such a big
problem because the interface methods should not be modified anyway (or
else programs using your code won't be compatible anymore), and for
private code, you can use search and replace to facilitate the operation.

We (my firm and project team) are currently talking quite a lot about
this issue because we are setting up guidelines for our next project (in
C#), and my opinion is that we will follow Microsoft's recommendation
and abandon the Ungarish notation. I regret this, but it seems to be the
trend nowadays.

HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #4

P: n/a
Laurent Bugnion wrote:
While I personally favour the Ungarish notation for identifiers (if only
because it helps to find a variable faster when you use an Intellisense
IDE like Visual Studio.NET), it should be noted that Microsoft
recommends abandoning the Ungarish notation. The reasons given is:
1) It makes the code language dependant, because not every language has
the same type (or at least not the same type names). I think that this
can be overcome by simply standardizing the prefixes for the set of
languages one uses.
2) It makes maintaining the code more difficult, because if you change
the type of an identifier while developing or maintaining the code, you
must also change the identifier name. I don't think it's such a big
problem because the interface methods should not be modified anyway (or
else programs using your code won't be compatible anymore), and for
private code, you can use search and replace to facilitate the operation.

We (my firm and project team) are currently talking quite a lot about
this issue because we are setting up guidelines for our next project (in
C#), and my opinion is that we will follow Microsoft's recommendation
and abandon the Ungarish notation. I regret this, but it seems to be the
trend nowadays.


Reading this through again at again, I cannot resolve the major issue:
First you tell us that you favour the Ungarish notation and while
citing what Microsoft recommends you successfully disprove these
recommendations. But finally you tell us that it is your *opinion*
to follow exactly the recommendations you have just disproved and
at the same time you regret that. Now where is the logic in that?
PointedEars

P.S.
I don't think you should use the name of your company in the From
header, unless you post in their name or cannot change that.
Jul 20 '05 #5

P: n/a
Hi,

Thomas 'PointedEars' Lahn wrote:
Laurent Bugnion wrote:

While I personally favour the Ungarish notation for identifiers (if only
because it helps to find a variable faster when you use an Intellisense
IDE like Visual Studio.NET), it should be noted that Microsoft
recommends abandoning the Ungarish notation. The reasons given is:
1) It makes the code language dependant, because not every language has
the same type (or at least not the same type names). I think that this
can be overcome by simply standardizing the prefixes for the set of
languages one uses.
2) It makes maintaining the code more difficult, because if you change
the type of an identifier while developing or maintaining the code, you
must also change the identifier name. I don't think it's such a big
problem because the interface methods should not be modified anyway (or
else programs using your code won't be compatible anymore), and for
private code, you can use search and replace to facilitate the operation.

We (my firm and project team) are currently talking quite a lot about
this issue because we are setting up guidelines for our next project (in
C#), and my opinion is that we will follow Microsoft's recommendation
and abandon the Ungarish notation. I regret this, but it seems to be the
trend nowadays.

Reading this through again at again, I cannot resolve the major issue:
First you tell us that you favour the Ungarish notation and while
citing what Microsoft recommends you successfully disprove these
recommendations. But finally you tell us that it is your *opinion*
to follow exactly the recommendations you have just disproved and
at the same time you regret that. Now where is the logic in that?


I said that my opinion is that we *will* follow Microsoft's
recommendation. I also said that I regret that this is what we will do,
because I favour ungarish notation. I don't see a contradiction in that.
When you're in a team, you follow the team's decisions even if you would
prefer to do something else.
PointedEars

P.S.
I don't think you should use the name of your company in the From
header, unless you post in their name or cannot change that.


Well, my firm is Siemens Building Technologies, and I didn't post in
their name (though I would if I wanted to). GalaSoft is just a hobby.
GalaSoft is me. I post in my name.

Besides, how is that your problem anyway?

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #6

P: n/a
On Mon, 29 Dec 2003 11:12:44 +0100, "Laurent Bugnion, GalaSoft"
<galasoft-LB@bluewin_NO_SPAM.ch> wrote:
While I personally favour the Ungarish notation for identifiers (if only
because it helps to find a variable faster when you use an Intellisense
IDE like Visual Studio.NET),
Really? I find it harder to find as everything begins with the same
f'in character!
it should be noted that Microsoft
recommends abandoning the Ungarish notation.


So that's why I've seen it going out of favour, I'm pleased, in IDE's
they'll generally tell you the type anyway.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #7

P: n/a
Hi Jim,

Jim Ley wrote:
On Mon, 29 Dec 2003 11:12:44 +0100, "Laurent Bugnion, GalaSoft"
<galasoft-LB@bluewin_NO_SPAM.ch> wrote:

While I personally favour the Ungarish notation for identifiers (if only
because it helps to find a variable faster when you use an Intellisense
IDE like Visual Studio.NET),

Really? I find it harder to find as everything begins with the same
f'in character!


I am well aware that ungarish notation is much of a personal taste. Some
hate it and some love it. Me, I am moderate usually and I like it ;-)

In general, when I look for an identifier in Intellisense, my first
question is "what type does it have" before I ask myself "how is it
named?". That's why ungarish notation rather helps me to find things
faster. That said, I can also live without it.

it should be noted that Microsoft
recommends abandoning the Ungarish notation.

So that's why I've seen it going out of favour, I'm pleased, in IDE's
they'll generally tell you the type anyway.

Jim.


True, but the identifiers aren't grouped according to the type.

Regards,

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #8

P: n/a
Thanks for all the examples.

Sincerely,
Frank

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #9

P: n/a
Laurent Bugnion, GalaSoft wrote:
Thomas 'PointedEars' Lahn wrote:
[...]
First you tell us that you favour the Ungarish notation and while
citing what Microsoft recommends you successfully disprove these
recommendations. But finally you tell us that it is your *opinion*
to follow exactly the recommendations you have just disproved and
at the same time you regret that. Now where is the logic in that?
I said that my opinion is that we *will* follow Microsoft's
recommendation. I also said that I regret that this is what we will do,
because I favour ungarish notation. I don't see a contradiction in that.
When you're in a team, you follow the team's decisions even if you would
prefer to do something else.


I understand now that you most certainly meant `opinion' as `outlook'.
I knew the word only in the meaning of `attitude' previously.
P.S.
I don't think you should use the name of your company in the From
header, unless you post in their name or cannot change that.


Well, my firm is Siemens Building Technologies, and I didn't post in
their name (though I would if I wanted to). GalaSoft is just a hobby.
GalaSoft is me. I post in my name.


ACK
Besides, how is that your problem anyway?


If that would be the name of your company, it could get you in
trouble if not intended by the company. Otherwise it could get
you in trouble, too, posting private at work. Now as it is
only a hobby, it may look like posing yourselves. You may have
noted that you happen to be one of the few posters here to use
a company name in the From header.

But since I note that your From address is none, it happens to
become your problem alone as I will not read your articles anymore.

[en] <http://www.interhack.net/pubs/munging-harmful/>
[de] <http://www.gerlo.de/falsche-email-adressen.html>
HTH & HAND

PointedEars
Jul 20 '05 #10

P: n/a
Hi,

Thomas 'PointedEars' Lahn wrote:

<snip>
If that would be the name of your company, it could get you in
trouble if not intended by the company. Otherwise it could get
you in trouble, too, posting private at work. Now as it is
only a hobby, it may look like posing yourselves. You may have
noted that you happen to be one of the few posters here to use
a company name in the From header.
Yes, I do this for years (literally), and I notice that you're the first
one to ever comment about it. Which brings me back to my original
comment: Why is that even your problem? It's comp.lang.javascript here,
not comp.lang.i.give.advices.about.everything
But since I note that your From address is none, it happens to
become your problem alone as I will not read your articles anymore.
Good riddance.
[en] <http://www.interhack.net/pubs/munging-harmful/>
[de] <http://www.gerlo.de/falsche-email-adressen.html>
I read that before you even started posting here. My opinion (means:
What I believe) is that it's bullshit. The internet has other, much more
serious problems to fear. One of those is people posting tons of
offtopic messages to programming newsgroups to appear knowledgeable.
HTH & HAND

PointedEars


Whatever,

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #11

P: n/a
JRS: In article <3F**************@PointedEars.de>, seen in
news:comp.lang.javascript, Thomas 'PointedEars' Lahn
<Po*********@web.de> posted at Wed, 31 Dec 2003 20:01:11 :-

But since I note that your From address is none, it happens to
become your problem alone as I will not read your articles anymore.


Have you considered using the services of a psychiatrist?

--
John Stockton, Surrey, UK. ??*@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
Jul 20 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.