473,413 Members | 1,854 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,413 software developers and data experts.

Validation Question


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 it’s
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
11 1424
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 it’s
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: wumingshi | last post by:
Hi, When validating an XML instance, sometimes the schema is not enough to expression the validation rules. Additional validation rules may be expressed in an application-specific way. For...
9
by: rbronson1976 | last post by:
Hello all, I have a very strange situation -- I have a page that validates (using http://validator.w3.org/) as "XHTML 1.0 Strict" just fine. This page uses this DOCTYPE: <!DOCTYPE html PUBLIC...
16
by: Hosh | last post by:
I have a form on a webpage and want to use JavaScript validation for the form fields. I have searched the web for form validation scripts and have come up with scripts that only validate...
1
by: Colin Basterfield | last post by:
Hi, I have a web form which takes daily sales totals, both counts and monetary value and is done on a weekly basis, so on a Monday morning the User would enter these totals. Each total has a...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
5
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and...
8
by: Joe | last post by:
Hi, I have a form with three text fields and a Submit button. The two text fields have ReqiredFieldValidator and third text field has RegularExpressionValidator. The page validation works fine...
2
by: winnie_us99 | last post by:
Hi All, I am trying to do validation on my text field before going to the next page to create a user. It doesn't look like the next button will fire any validation. Am I missing something? Can...
9
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.