01.
<script language=
"javascript"
>
02.
function
test(Quality,Stock){
03.
04.
var
Qty=document.getElementById(Quanlity).value;
05.
var
Stock=document.getElementById(Stock).value;
06.
07.
if
(Stock-Qty<0){
08.
alert(
'สินค้าไม่เพียงพอ'
);
09.
return
false;
10.
}
11.
}
12.
13.
14.
</script>
15.
16.
17.
<form id=
"f1"
method=
"post"
action=
"?"
onsubmit=
"return test('Quanltiy','Stock')"
>
18.
<input type=
"text"
name=
"Quanlity"
id=
"Quanlity"
value=
""
/>
19.
<input type=
"hidden"
name=
"Stock"
id=
"Stock"
value=
"10"
/>
20.
<input type=
"submit"
/>
21.
</form>