|
#1
|
|||
|
|||
|
Hi!
I have a litte problem with my CustomValidator. What my CustomValidator should do: The CustomValidator should check if 2 textboxes are empty.. if yes he should diplay a message. This is my code: Code:
<asp:customvalidator id="CustomValidator1" runat="server" ErrorMessage="Sie müssen min. 1 Telefonnummer angeben" Display="Static" OnServerValidate="ValidateExistanceOfPhones"></asp:customvalidator></P> Code:
<script runat="server">
void ValidateExistanceOfPhones(object source, ServerValidateEventArgs args)
{
args.IsValid = !((m_txtTelephoneNumber.Text.Length == 0) && (m_txtMobileNumber.Text.Length == 0));
}
</script>
the calidator check ValidateExistanceOfPhones. but when args.IsValid = false the message isn't shown. What is the problem??! Make I something wrong? 2. quastion: is it possible to check the state of the 2 textboxes on the client side? when YES how? best regards, gicio |
|
#2
|
|||
|
|||
|
I have no experience of ASP, however it's definitely possible to use JavaScript to validate this on the client side.
Code:
<script>
function validate(){
score=0
if(document.myform.text1.value=""){
message="text1 has not been filled in"
score++
}
if(document.myform.text2.value=""){
score++
message="text2 has not been filled in"
}
if(score==0){
document.myform.submit()
}else{
alert(message);
}
}
</script>
<form action="yourscript.asp" name="myform">
<input type="text" name="text1" />
<input type="text" name="text2" />
<input type="button" onclick="validate()" value="Go">
</form>
__________________
Don't forget to post back with the results |
![]() |
| Bookmarks |
«
Previous Topic
|
Next Topic
»
| Topic Tools | |
|
|
All times are GMT +1. The time now is 02:50 AM.
[
RSS ]








