I am currently having a html code as:
<input type="text" name="price1" size="14" value="Rs.900" readonly="readonly"/>
<input type="text" name="price2" size="14" value="Rs.600" readonly="readonly"/>
<input type="text" name="price3" size="14" value="Rs.500" readonly="readonly"/>
<form name="qty">
<input type="text" name="quant1" id="id1" size="14" value="0"/>
<input type="text" name="quant2" id="id2" size="14" value="0" />
<input type="text" name="quant3" id="id3" size="14" value="0" />
<input type="button" onclick="calculate()" value="Submit" />

On clicking the submit button i want the value entered in qty form gets multiplied by corresponding price & gets returned using a javascript function.
Also how to validate the qty form, so as to allow only numeric values.
Please respond.

Thanks in Advance

Edited by khanrock: n/a

6 Years
Discussion Span
Last Post by partha.asp

<style type="text/css">

<script type ="text/javascript">
function validate(f11)
var a =f11.t2.value;
var b =f11.t3.value;
var c =/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var d =f11.t4.value;
var x = /^([A-Za-z0-9]){6,10}$/;
var y = f11.t5.value;
var passwd= /^([A-Za-z0-9_\-\.\@\)\(\+]){8,20}$/;
var phnoe = /^([0-9]){10,12}$/;
var phno = f11.tp.value;

alert("please fill the field");
return false;

<!-- validation using regular expression so that phone no must be within 10 to 12 and contain numbers only-->

if(phnoe.test(phno)== false)
alert("please re enter valid phone no ");
return false;
<!-- validation using regular expression so that password must not contain some special charector only & should be within 8 to 20-->
if(passwd.test(b)== false)
alert("your password is not between 8 to 20 or containing unsupported charector");
return false;

alert("please re enter");
return false;
if(c.test(d)== false)
alert("please re enter valid email id ");
return false;
<!-- validation using regular expression so that username must not contain special charector & should be within 6 to 10-->
if(x.test(y)== false)
alert(" username must not contain special charector & should be within 6 to 10");
return false;

<!-- validation for dropdown list-->

if(document.f1.car.selectedIndex <=0)
alert("please select a car");

return false;

<!-- validation for radio button-->

var radioselected=false;
for(i=0; i<document.f1.gender.length; i++)
alert("please select at least one gender value");


<!-- validation for checkbox -->
if (document.f1.c1.checked == false &&
document.f1.c2.checked == false &&
document.f1.c3.checked == false)
alert ('You didn\'t choose any of the checkboxes!');
return false;

<body bgcolor = "olive">
<div class ="style1" >

<form name ="f1" onsubmit = "return validate(this)">

<h1> form validation using javascript </h1>
name<input type ="text" name="t1" value=""/> <P>

phone no<input type ="text" name="tp" value=""/><P>
password:<input type ="password" name="t2" value=""/> <P>
re enter :<input type ="password" name="t3" value=""/> <P>
email ::<input type ="text" name="t4" value=""/> <P>

<!-- user name field-->
desired username: <input type ="text" name="t5" value=""/> <P>

<!--drop down list-->
car :<select name="car">
<option value="0" selected="selected">Select One</option>
<option value ="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value= "bike">bike</option>
<option value ="santro">Santro</option>

</select> <p>
<!-- radio button field -->
select geder:<input type="radio" name="gender" value="female ">FEMALE
<input type="radio" name="gender" value="male ">MALE <p>

<!-- checkbox field -->
select course :
<input type="checkbox" name="c1" value="c++" />C++
<input type="checkbox" name="c2" value="java" />CORE JAVA
<input type="checkbox" name="c3" value="os" />OS <p>

<input type ="submit" value ="click">


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.