473,732 Members | 2,227 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom Validation Cntrl

Created a Custom Validation Ctrl in EW2 to validate a text box entry. Want
to make sure entry is evenly divisible by 7, and that value is not 0.
However, args.IsValid = false, even if 77 is entered in text box. Tag and
script that were added to page follow:

<asp:CustomVali dator id="CustomValid ator1" runat="server"
ClientValidatio nFunction="Clie ntValidateSeria l3"
ControlToValida te="SerialNumbe r3" Display="Dynami c" ErrorMessage="E ntry
Invalid"></asp:CustomValid ator>

<script type="text/javascript">

function ClientValidateS erial3(source, args) {

if(args.value == 0) {

args.IsValid = false;
return;
}

if(args.value % 7 == 0) {

args.IsValid = true;
}
else {

args.IsValid = false;
}
}

</script>

This is my first attemp at using a Custom Validator and using javascript.

Serverside code for validation was not present when I tested the above
script in EW2.

Also posted question on EW discussion group.

Thanks for any tips/information.

--
Gary Larimer
Oct 5 '08 #1
5 1278
Why are you checking args.value?

If the value that needs to be validated is in a textbox, then that is what
you should be checking. This code should do what you're looking for:

<script type="text/javascript">

function ClientValidateS erial3(source, args) {

args.IsValid = false;

if (Textbox1.value % 7 == 0)
{
args.IsValid = true;
}
</script>

Also, don't forget to write the same logic, but in the ServerValidate event
for the customValidator control.

-Scott

"Gary Larimer" <Ga*********@di scussions.micro soft.comwrote in message
news:03******** *************** ***********@mic rosoft.com...
Created a Custom Validation Ctrl in EW2 to validate a text box entry.
Want
to make sure entry is evenly divisible by 7, and that value is not 0.
However, args.IsValid = false, even if 77 is entered in text box. Tag and
script that were added to page follow:

<asp:CustomVali dator id="CustomValid ator1" runat="server"
ClientValidatio nFunction="Clie ntValidateSeria l3"
ControlToValida te="SerialNumbe r3" Display="Dynami c" ErrorMessage="E ntry
Invalid"></asp:CustomValid ator>

<script type="text/javascript">

function ClientValidateS erial3(source, args) {

if(args.value == 0) {

args.IsValid = false;
return;
}

if(args.value % 7 == 0) {

args.IsValid = true;
}
else {

args.IsValid = false;
}
}

</script>

This is my first attemp at using a Custom Validator and using javascript.

Serverside code for validation was not present when I tested the above
script in EW2.

Also posted question on EW discussion group.

Thanks for any tips/information.

--
Gary Larimer

Oct 5 '08 #2
you almost had it. the original javascript code used with webforms
breaks with convention and starts properties with a capital letter, so
its "args.Value ".

-- bruce (sqlwork.com)
Gary Larimer wrote:
Created a Custom Validation Ctrl in EW2 to validate a text box entry. Want
to make sure entry is evenly divisible by 7, and that value is not 0.
However, args.IsValid = false, even if 77 is entered in text box. Tag and
script that were added to page follow:

<asp:CustomVali dator id="CustomValid ator1" runat="server"
ClientValidatio nFunction="Clie ntValidateSeria l3"
ControlToValida te="SerialNumbe r3" Display="Dynami c" ErrorMessage="E ntry
Invalid"></asp:CustomValid ator>

<script type="text/javascript">

function ClientValidateS erial3(source, args) {

if(args.value == 0) {

args.IsValid = false;
return;
}

if(args.value % 7 == 0) {

args.IsValid = true;
}
else {

args.IsValid = false;
}
}

</script>

This is my first attemp at using a Custom Validator and using javascript.

Serverside code for validation was not present when I tested the above
script in EW2.

Also posted question on EW discussion group.

Thanks for any tips/information.
Oct 5 '08 #3
this is a bad practice. your javascript should be checking args.Value,
not looking up the control by name otherwise the validator is not
reusable. if you need other control properties, the source is the
validator control from which you access the actual control with
"source.control tovalidate"

-- bruce (sqlwork.com)

Scott M. wrote:
Why are you checking args.value?

If the value that needs to be validated is in a textbox, then that is what
you should be checking. This code should do what you're looking for:

<script type="text/javascript">

function ClientValidateS erial3(source, args) {

args.IsValid = false;

if (Textbox1.value % 7 == 0)
{
args.IsValid = true;
}
</script>

Also, don't forget to write the same logic, but in the ServerValidate event
for the customValidator control.

-Scott

"Gary Larimer" <Ga*********@di scussions.micro soft.comwrote in message
news:03******** *************** ***********@mic rosoft.com...
>Created a Custom Validation Ctrl in EW2 to validate a text box entry.
Want
to make sure entry is evenly divisible by 7, and that value is not 0.
However, args.IsValid = false, even if 77 is entered in text box. Tag and
script that were added to page follow:

<asp:CustomVal idator id="CustomValid ator1" runat="server"
ClientValidati onFunction="Cli entValidateSeri al3"
ControlToValid ate="SerialNumb er3" Display="Dynami c" ErrorMessage="E ntry
Invalid"></asp:CustomValid ator>

<script type="text/javascript">

function ClientValidateS erial3(source, args) {

if(args.value == 0) {

args.IsValid = false;
return;
}

if(args.value % 7 == 0) {

args.IsValid = true;
}
else {

args.IsValid = false;
}
}

</script>

This is my first attemp at using a Custom Validator and using javascript.

Serverside code for validation was not present when I tested the above
script in EW2.

Also posted question on EW discussion group.

Thanks for any tips/information.

--
Gary Larimer

Oct 5 '08 #4
Thank you for the replies.

Changing args.value to args.Value solved the problem.
--
Gary Larimer
"Gary Larimer" wrote:
Created a Custom Validation Ctrl in EW2 to validate a text box entry. Want
to make sure entry is evenly divisible by 7, and that value is not 0.
However, args.IsValid = false, even if 77 is entered in text box. Tag and
script that were added to page follow:

<asp:CustomVali dator id="CustomValid ator1" runat="server"
ClientValidatio nFunction="Clie ntValidateSeria l3"
ControlToValida te="SerialNumbe r3" Display="Dynami c" ErrorMessage="E ntry
Invalid"></asp:CustomValid ator>

<script type="text/javascript">

function ClientValidateS erial3(source, args) {

if(args.value == 0) {

args.IsValid = false;
return;
}

if(args.value % 7 == 0) {

args.IsValid = true;
}
else {

args.IsValid = false;
}
}

</script>

This is my first attemp at using a Custom Validator and using javascript.

Serverside code for validation was not present when I tested the above
script in EW2.

Also posted question on EW discussion group.

Thanks for any tips/information.

--
Gary Larimer
Oct 6 '08 #5
I disagree. As a customvalidator , its use would not necessarially need to
be written as reusable.
"bruce barker" <no****@nospam. comwrote in message
news:u4******** ******@TK2MSFTN GP03.phx.gbl...
this is a bad practice. your javascript should be checking args.Value, not
looking up the control by name otherwise the validator is not reusable. if
you need other control properties, the source is the validator control
from which you access the actual control with "source.control tovalidate"

-- bruce (sqlwork.com)

Scott M. wrote:
>Why are you checking args.value?

If the value that needs to be validated is in a textbox, then that is
what you should be checking. This code should do what you're looking
for:

<script type="text/javascript">

function ClientValidateS erial3(source, args) {

args.IsValid = false;

if (Textbox1.value % 7 == 0)
{
args.IsValid = true;
}
</script>

Also, don't forget to write the same logic, but in the ServerValidate
event for the customValidator control.

-Scott

"Gary Larimer" <Ga*********@di scussions.micro soft.comwrote in message
news:03******* *************** ************@mi crosoft.com...
>>Created a Custom Validation Ctrl in EW2 to validate a text box entry.
Want
to make sure entry is evenly divisible by 7, and that value is not 0.
However, args.IsValid = false, even if 77 is entered in text box. Tag
and
script that were added to page follow:

<asp:CustomVa lidator id="CustomValid ator1" runat="server"
ClientValidat ionFunction="Cl ientValidateSer ial3"
ControlToVali date="SerialNum ber3" Display="Dynami c" ErrorMessage="E ntry
Invalid"></asp:CustomValid ator>

<script type="text/javascript">

function ClientValidateS erial3(source, args) {

if(args.value == 0) {

args.IsValid = false;
return;
}

if(args.value % 7 == 0) {

args.IsValid = true;
}
else {

args.IsValid = false;
}
}

</script>

This is my first attemp at using a Custom Validator and using
javascript.

Serverside code for validation was not present when I tested the above
script in EW2.

Also posted question on EW discussion group.

Thanks for any tips/information.

--
Gary Larimer
Oct 6 '08 #6

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

Similar topics

2
3733
by: Barbara Alderton | last post by:
I setup some standard Required Field Validation controls and one Custom validation control on an ASP.NET page (within a user control) to validate text entry. I also setup a Summary Control to post all the messages to a message box (ShowMessageBox=true). The required field validation error messages show up in the summary just fine but I can't get the custom validation message to show up if invalid. So far I have the summary control...
1
2429
by: Stephen Adam | last post by:
Hi there, I have written a custom validation control which checks to see of an input field is not empty and contains only numeric data. I was using a regular expression validation control but was unable to get it fail if a field was blank. My problem now is that while my custom validation control will detect if a field matches my requirement and will display a error message if it doesnt, it wont stop it from being used and sent to my...
5
2646
by: | last post by:
Hi all, Has anyone been able to write some custom javascript on the onclick event of submit button to do certain things like disable submit button, only submit form once etc. This was a breeze in 1.1 since I could edit the .js file. Now in 2.0 I can no longer do this. Also, my code would have to be called after all client-side validation was done and was successful. Any ideas? TIA!
9
3137
by: wardy1975 | last post by:
Hi All, Looking for a little expert advice on a few web standards issues. I am currently trying to understand the impact of web standards for a web application I work with. I have been doing a lot of research in the areas of XHTML and WAI compliance, and am attempting to come up with a recommendation for our product in terms of standards level compliance. Ideally, I would like to be at XHTML 1.0 Strict. However, in my reading I have...
0
1061
by: Marek | last post by:
Hi all, I have custrom control with four elements: text box, regular expression validator, required field validator and custom validator. Next this control is dragged on to web site with several controls. All controls has the same validation group. When I press button for this validation group then all validations runs ok except custom validation. When this push button is removed from validation group then custom validation runs ok but...
3
8249
by: Andy | last post by:
Hi folks, I have a customvalidator control that works properly if it isn't contained in an ASP:TABLE. But, when I place it inside an ASP:TABLE, I find that _ServerValidate doesn't get fired, even if I force the customvalidator to validate by invoking its validate() method after a button is clicked: cvCustomValidator_ServerValidate(object source, system.Web.UI.WebControls.ServerValidateEventArgs args) <== doesn't get
1
3791
gagandeepgupta16
by: gagandeepgupta16 | last post by:
Hi I am working on an entry form using validation controls in ASP.NET. I have two controls which requires custom validators, no issue in using plain custom validators. But when i am using Validation Callout Extender with the custom validators its not working properly. here is the link where i got solution for one custom validator with validation callout extender :- http://www.junnark.com/Articles/Article0001.aspx I searched a lot but...
2
19484
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8774
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9447
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9235
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9181
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6031
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.