...

View Full Version : second form validation



hema
06-01-2004, 05:39 AM
Hi in my jsp page,i have 2 forms.
one is a main form with few fields which i ahve done the validations
there's another form which is a table with multiple rows for users to enter.
how do i do the validation for it.

suppose there's a id in 2nd form with 5 rows how do i validate the field for 5 rows.

pls advise

glenngv
06-01-2004, 06:58 AM
You have to post your codes in order for us to help you.

hema
06-01-2004, 07:33 AM
have attached the code

how do i do the validation for risklist,reinsurance which are a multiple rows .

the 2 list are a separate form placed in the main form .


pls advise

hema
06-01-2004, 07:37 AM
Glenn,

sorry i never attached earlier,now attached the file with this reply.

pls advise

hema
06-03-2004, 05:52 AM
can anyone help this problem,i have attached the script in my previous reply.

waiting for a reply.

thanks

glenngv
06-03-2004, 07:10 AM
You should post the generated HTML source not the server-side script source. Execute the page then save the html and post it here. And please describe your problem in more detail.

hema
06-03-2004, 08:00 AM
i have attached the view source of my html page.

in my page i have got a table called riskList with a field riskNo which iterates.

i display the rows for user to enter riskNo.so i want to validate so that they enter a valid no without decimals.

pls help

hopw u understood.

glenngv
06-03-2004, 09:58 AM
You are already validating each field onchange.

<input type="text" name="riskList[0].riskNo" value="2.4" onchange="checkNo(this)" class="inputTxt">

Does checkNo() also check for decimal numbers? I can't see the function because it is in global.js.

hema
06-03-2004, 10:12 AM
yes i tries to check but it prmpts the user only once to enter a valid field after that the focus goes to the next field.

though i forcefully keep my focus there are click on tab the second time it never prompts the message.

pls advise

glenngv
06-03-2004, 10:46 AM
For consistency, validate the Risk Nos too after the Save button is clicked, as in other fields.

You can optimize your saveAction() function if you pass the form reference to it.


<input type="button" name="btnSave" value="Save" onclick="saveAction(this.form)" />
...
function saveAction(f)
{
if (!validDate(f.entryDate,"Entry Date",true))
return false;
if (!validInt(f.cedPolNo,"Ced Pol no"))
return false;
if (!validRequired(f.policyType,"Policy Type"))
return false;

...

//validate Risk Nos.
var ctr=0;
var el;
while (el=f.elements["riskList["+(ctr++)+"].riskNo"]){
if (!validNum(el,"RiskNo")){
el.focus();
return false;
}
}
...
}

hema
06-03-2004, 11:50 AM
thanks a lot its working now



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum