473,411 Members | 2,013 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,411 software developers and data experts.

Javascript question on customvalidation

Hi

I have a set of Yes/No radio buttons with textboxes for each. I need to
write a common customvalidation function that checks, if radiobutton "yes"
is selected, the value in the corresponding textbox should be greater than
0.

For eg:
IsVM Qty: <radX0Yes> YES <radX0No> NO Qty: <txt00>
IsVM1 Qty: <radX1Yes> YES <radX1Yes> NO Qty: <txt11>
IsVM2 Qty: <radX2Yes> YES <radX2Yes> NO Qty: <txt22>
IsVM3 Qty: <radX3Yes> YES <radX3Yes> NO Qty: <txt33>

I created a customvalidator with clientsidevalidation for each set.
<asp:CustomValidator id="cvVM" runat="server" ErrorMessage="Required"
ControlToValidate="txtVMQty"
ClientValidationFunction="ValidateQty('radX0Yes',' txt00')"></asp:CustomValid
ator>

function ValidateQty(objRadId,objTxtBoxId){

if (document.getElementById(objRadId).checked){

if (document.getElementById(objTxtBoxId).value <= 0){

arguments.IsValid = false; ??????

}}}

How can i make the arguments.IsValid to false or true based on the
condition?

Thanks
Gane
Nov 19 '05 #1
5 4132
It should be just this: ClientValidationFunction="ValidateQty"

And the signature of the method should take 2 arguments, the first is the
validation tag and the seconds is the args to say if valdation passed or not:

function ValidateQty(sender, args){
if (document.getElementById(sender.controltovalidate) .checked){
if (document.getElementById(sender.controltovalidate) .value <= 0){

args.IsValid = false;

}}}

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

I have a set of Yes/No radio buttons with textboxes for each. I need
to write a common customvalidation function that checks, if
radiobutton "yes" is selected, the value in the corresponding textbox
should be greater than 0.

For eg:
IsVM Qty: <radX0Yes> YES <radX0No> NO Qty: <txt00>
IsVM1 Qty: <radX1Yes> YES <radX1Yes> NO Qty: <txt11>
IsVM2 Qty: <radX2Yes> YES <radX2Yes> NO Qty: <txt22>
IsVM3 Qty: <radX3Yes> YES <radX3Yes> NO Qty: <txt33>
I created a customvalidator with clientsidevalidation for each set.
<asp:CustomValidator id="cvVM" runat="server" ErrorMessage="Required"
ControlToValidate="txtVMQty"
ClientValidationFunction="ValidateQty('radX0Yes',' txt00')"></asp:Custo
mValid

function ValidateQty(objRadId,objTxtBoxId){

if (document.getElementById(objRadId).checked){

if (document.getElementById(objTxtBoxId).value <= 0){

arguments.IsValid = false; ??????

}}}

How can i make the arguments.IsValid to false or true based on the
condition?

Thanks
Gane


Nov 19 '05 #2
It should be just this: ClientValidationFunction="ValidateQty"

And the signature of the method should take 2 arguments, the first is the
validation tag and the seconds is the args to say if valdation passed or not:

function ValidateQty(sender, args){
if (document.getElementById(sender.controltovalidate) .checked){
if (document.getElementById(sender.controltovalidate) .value <= 0){

args.IsValid = false;

}}}

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

I have a set of Yes/No radio buttons with textboxes for each. I need
to write a common customvalidation function that checks, if
radiobutton "yes" is selected, the value in the corresponding textbox
should be greater than 0.

For eg:
IsVM Qty: <radX0Yes> YES <radX0No> NO Qty: <txt00>
IsVM1 Qty: <radX1Yes> YES <radX1Yes> NO Qty: <txt11>
IsVM2 Qty: <radX2Yes> YES <radX2Yes> NO Qty: <txt22>
IsVM3 Qty: <radX3Yes> YES <radX3Yes> NO Qty: <txt33>
I created a customvalidator with clientsidevalidation for each set.
<asp:CustomValidator id="cvVM" runat="server" ErrorMessage="Required"
ControlToValidate="txtVMQty"
ClientValidationFunction="ValidateQty('radX0Yes',' txt00')"></asp:Custo
mValid

function ValidateQty(objRadId,objTxtBoxId){

if (document.getElementById(objRadId).checked){

if (document.getElementById(objTxtBoxId).value <= 0){

arguments.IsValid = false; ??????

}}}

How can i make the arguments.IsValid to false or true based on the
condition?

Thanks
Gane


Nov 19 '05 #3
i am trying to write a general function.
I need to pass the webcontrol ids as paramater to the function as well.

the code looks like and i have similar codeblocks like below
---------
<asp:radiobutton id="radVMYes" runat="server" CssClass="radbtn" Text="Yes"
GroupName="radVM"></asp:radiobutton>
<asp:radiobutton id="radVMNo" runat="server" CssClass="radbtn" Text="No"
GroupName="radVM" Checked = "true"></asp:radiobutton>
&nbsp;&nbsp;Qty:&nbsp;<asp:textbox id="txtVMQty" runat="server" Columns="2"
cssclass="txtinput" enabled = "false">0</asp:textbox>
<asp:CustomValidator id="cvVMail" runat="server" ErrorMessage="Required"
ControlToValidate="txtVMQty"
ClientValidationFunction="ValidateQty"></asp:CustomValidator>
----------

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:46**********************@msnews.microsoft.com ...
It should be just this: ClientValidationFunction="ValidateQty"

And the signature of the method should take 2 arguments, the first is the
validation tag and the seconds is the args to say if valdation passed or not:
function ValidateQty(sender, args){
if (document.getElementById(sender.controltovalidate) .checked){
if (document.getElementById(sender.controltovalidate) .value <= 0){

args.IsValid = false;

}}}

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

I have a set of Yes/No radio buttons with textboxes for each. I need
to write a common customvalidation function that checks, if
radiobutton "yes" is selected, the value in the corresponding textbox
should be greater than 0.

For eg:
IsVM Qty: <radX0Yes> YES <radX0No> NO Qty: <txt00>
IsVM1 Qty: <radX1Yes> YES <radX1Yes> NO Qty: <txt11>
IsVM2 Qty: <radX2Yes> YES <radX2Yes> NO Qty: <txt22>
IsVM3 Qty: <radX3Yes> YES <radX3Yes> NO Qty: <txt33>
I created a customvalidator with clientsidevalidation for each set.
<asp:CustomValidator id="cvVM" runat="server" ErrorMessage="Required"
ControlToValidate="txtVMQty"
ClientValidationFunction="ValidateQty('radX0Yes',' txt00')"></asp:Custo
mValid

function ValidateQty(objRadId,objTxtBoxId){

if (document.getElementById(objRadId).checked){

if (document.getElementById(objTxtBoxId).value <= 0){

arguments.IsValid = false; ??????

}}}

How can i make the arguments.IsValid to false or true based on the
condition?

Thanks
Gane


Nov 19 '05 #4
i am trying to write a general function.
I need to pass the webcontrol ids as paramater to the function as well.

the code looks like and i have similar codeblocks like below
---------
<asp:radiobutton id="radVMYes" runat="server" CssClass="radbtn" Text="Yes"
GroupName="radVM"></asp:radiobutton>
<asp:radiobutton id="radVMNo" runat="server" CssClass="radbtn" Text="No"
GroupName="radVM" Checked = "true"></asp:radiobutton>
&nbsp;&nbsp;Qty:&nbsp;<asp:textbox id="txtVMQty" runat="server" Columns="2"
cssclass="txtinput" enabled = "false">0</asp:textbox>
<asp:CustomValidator id="cvVMail" runat="server" ErrorMessage="Required"
ControlToValidate="txtVMQty"
ClientValidationFunction="ValidateQty"></asp:CustomValidator>
----------

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:46**********************@msnews.microsoft.com ...
It should be just this: ClientValidationFunction="ValidateQty"

And the signature of the method should take 2 arguments, the first is the
validation tag and the seconds is the args to say if valdation passed or not:
function ValidateQty(sender, args){
if (document.getElementById(sender.controltovalidate) .checked){
if (document.getElementById(sender.controltovalidate) .value <= 0){

args.IsValid = false;

}}}

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

I have a set of Yes/No radio buttons with textboxes for each. I need
to write a common customvalidation function that checks, if
radiobutton "yes" is selected, the value in the corresponding textbox
should be greater than 0.

For eg:
IsVM Qty: <radX0Yes> YES <radX0No> NO Qty: <txt00>
IsVM1 Qty: <radX1Yes> YES <radX1Yes> NO Qty: <txt11>
IsVM2 Qty: <radX2Yes> YES <radX2Yes> NO Qty: <txt22>
IsVM3 Qty: <radX3Yes> YES <radX3Yes> NO Qty: <txt33>
I created a customvalidator with clientsidevalidation for each set.
<asp:CustomValidator id="cvVM" runat="server" ErrorMessage="Required"
ControlToValidate="txtVMQty"
ClientValidationFunction="ValidateQty('radX0Yes',' txt00')"></asp:Custo
mValid

function ValidateQty(objRadId,objTxtBoxId){

if (document.getElementById(objRadId).checked){

if (document.getElementById(objTxtBoxId).value <= 0){

arguments.IsValid = false; ??????

}}}

How can i make the arguments.IsValid to false or true based on the
condition?

Thanks
Gane


Nov 19 '05 #5
You could place them as an attribute on your validator.

<asp:CustomValidator
id="cvVMail"
runat="server"
ErrorMessage="Required"
ClientValidationFunction="ValidateQty"
cbControl="radVMYes"
txtControl="txtVMQty"
/>

Notice I removed the ControlToValidate property.

Your custom validation will now look something like this.

function ValidateQty( object, args )
{
if ( document.all[object.cbControl].checked == true ) {
if ( document.all[object.txtControl].value == "" )
args.isValid = false;
}

args.isValid = true;
}

"gane kol" <ga*****@softca.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
i am trying to write a general function.
I need to pass the webcontrol ids as paramater to the function as well.

the code looks like and i have similar codeblocks like below
---------
<asp:radiobutton id="radVMYes" runat="server" CssClass="radbtn" Text="Yes"
GroupName="radVM"></asp:radiobutton>
<asp:radiobutton id="radVMNo" runat="server" CssClass="radbtn" Text="No"
GroupName="radVM" Checked = "true"></asp:radiobutton>
&nbsp;&nbsp;Qty:&nbsp;<asp:textbox id="txtVMQty" runat="server" Columns="2" cssclass="txtinput" enabled = "false">0</asp:textbox>
<asp:CustomValidator id="cvVMail" runat="server" ErrorMessage="Required"
ControlToValidate="txtVMQty"
ClientValidationFunction="ValidateQty"></asp:CustomValidator>
----------

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:46**********************@msnews.microsoft.com ...
It should be just this: ClientValidationFunction="ValidateQty"

And the signature of the method should take 2 arguments, the first is the validation tag and the seconds is the args to say if valdation passed or

not:

function ValidateQty(sender, args){
if (document.getElementById(sender.controltovalidate) .checked){
if (document.getElementById(sender.controltovalidate) .value <= 0){

args.IsValid = false;

}}}

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

I have a set of Yes/No radio buttons with textboxes for each. I need
to write a common customvalidation function that checks, if
radiobutton "yes" is selected, the value in the corresponding textbox
should be greater than 0.

For eg:
IsVM Qty: <radX0Yes> YES <radX0No> NO Qty: <txt00>
IsVM1 Qty: <radX1Yes> YES <radX1Yes> NO Qty: <txt11>
IsVM2 Qty: <radX2Yes> YES <radX2Yes> NO Qty: <txt22>
IsVM3 Qty: <radX3Yes> YES <radX3Yes> NO Qty: <txt33>
I created a customvalidator with clientsidevalidation for each set.
<asp:CustomValidator id="cvVM" runat="server" ErrorMessage="Required"
ControlToValidate="txtVMQty"
ClientValidationFunction="ValidateQty('radX0Yes',' txt00')"></asp:Custo
mValid

function ValidateQty(objRadId,objTxtBoxId){

if (document.getElementById(objRadId).checked){

if (document.getElementById(objTxtBoxId).value <= 0){

arguments.IsValid = false; ??????

}}}

How can i make the arguments.IsValid to false or true based on the
condition?

Thanks
Gane



Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rodchar | last post by:
hey all, I'm not sure if this is even possible but here goes: if i put a CustomValidator control in my EditItem template column how do i get to it? Or how and where do i write my custom code for...
2
by: kpg | last post by:
Hi all, This should be simple... I have a TextBox1 and a customvalidation control linked to it. I use a client side script to validate the textbox. If the data is not valid I want to return...
1
by: =?Utf-8?B?Ym9iYnk=?= | last post by:
I have a drop down list in my asp page. when I selectg an irem and click on a button it appears in the Grid view. But when I again come to the same page and click on the same item from Drop down...
1
by: Craig Buchanan | last post by:
I have a Web User Control (.ascx file) that I need to valid using a CustomValidation control. Moreover, I would like use client and server validation, if possible. I have the logic for the...
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: 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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.