hi
I used validation control for textboxs in page:
<asp:RequiredFieldValidator Display="Dynamic" ID="RequiredFieldValidator6" runat="server" ControlToValidate="TxtMName"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator Display="Dynamic" ID="RequiredFieldValidator8" runat="server" ControlToValidate="TxtaddC"></asp:RequiredFieldValidator>
<asp:ImageButton ID="ImageButton1" runat="server" CssClass="imgsaveM" ImageUrl="~/Image/admin/savef.png" OnClick="Imgsave_Click"></asp:ImageButton>
<script type="text/javascript">
function WebForm_OnSubmit() {
var message = document.getElementById("message");
message.style.display = "none";
if (typeof (ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) {
for (var i in Page_Validators) {
try {
if (!Page_Validators[i].isvalid) {
message.style.display = "block";
}
} catch (e) {
}
} return false;
} return true;
}
</script>
<div id="message" class="backS2fT1D">
موارد ستاره دار را به صورت صحیح وارد نمایید
</div>
and use watermark for textbox see below code:
<script type="text/javascript">
window.onload = function SetColorOnPageLoad() {
var defalutAddKaText = "آدرس را به صورت کامل و بدون نام استان یا شهر وارد نمایید.";
var defalutAddNaText = "آدرس را به صورت تقریبی و بدون نام استان یا شهر وارد نمایید.";
functionSetColor(document.getElementById("TxtaddC"), defalutAddKaText);
functionSetColor(document.getElementById("TxtaddCN"), defalutAddNaText);
}
function functionSetColor(Textbox, WaterMark) {
if (Textbox.value.length > 0 && Textbox.value == WaterMark) {
Textbox.style.color = "#b1b1b1";
} else {
Textbox.style.color = "black";
}
}
function WaterMark(txt, evt, msg) {
if (txt.value.length == 0 && evt.type == "blur") {
txt.style.color = "#b1b1b1";
txt.value = msg;
}
if (txt.value == msg && evt.type == "focus") {
txt.style.color = "black";
txt.value = "";
}
}
</script>
problem is that when I use watermark for textboxs validation doesn't work and if I doesn't fill textbox it doesn't show any error message
can you help me?
best regards
neda