IMP:ValidationSummary/CustomValidator/ResetBtn

S

SMG

Hi All.
My forms has two textboxes, 1 username, 2 password.
Both has requiredfield validator it works fine when there is no input in
these textboxes.
And the errorMsg is shown in ValidationSummary.

Now I want to check the username should contain only chatacters,
( I want to use customvalidator), when i enter char+number it trap the event
of customvalidator but it doesn't show the errormsg in the customValidator
and submits the form.

=======================
The Customvalidator & ValidationSummary code is as follows :
=======================
<asp:CustomValidator id="valCust" ErrorMessage="Please Enter Proper User
Name" ControlToValidate="txtUserName" Runat="server"></asp:CustomValidator>

<asp:ValidationSummary Runat="server" ID="valValSumm" Height="31px"
Width="281px"></asp:ValidationSummary>

=======================
The javascript function is as follows
=======================
function PropUserName(source, argument) {
var ValidChars = "abcdefghijklmnopqrstuvwxyz";
var Char; var sText=document.getElementById("txtUserName").value;
for (i = 0; i < sText.length; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
arguments.IsValid = false;
// alert("Please Enter Proper Name")
return;
}
} return;
}
====================

It gives the alert from the javascript function, but it doesn't show the
ErrorMsgs associated with CustomValidator??????

Can anyone tell me where I am wrong?

One more how do i reset the form values ?
Is there any other way than this "<input type=reset value=reset>" will my
error msgs will disappear with this? if not then how do i reset the form
values and disable the errormsgs in validationSummary.


regards,
SMG
 
J

John Saunders

SMG said:
Hi All.
My forms has two textboxes, 1 username, 2 password.
Both has requiredfield validator it works fine when there is no input in
these textboxes.
And the errorMsg is shown in ValidationSummary.

Now I want to check the username should contain only chatacters,
( I want to use customvalidator), when i enter char+number it trap the event
of customvalidator but it doesn't show the errormsg in the customValidator
and submits the form.

=======================
The Customvalidator & ValidationSummary code is as follows :
=======================
<asp:CustomValidator id="valCust" ErrorMessage="Please Enter Proper User
Name" ControlToValidate="txtUserName"
Runat="server"> said:
<asp:ValidationSummary Runat="server" ID="valValSumm" Height="31px"
Width="281px"></asp:ValidationSummary>

You do not reference your JavaScript function in your CustomValidator tag.

Take a look at ASP.NET Validation in Depth
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/htm
l/aspplusvalid.asp) from MSDN.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top