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
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