Validating textbox's

Posted by Mustafa_9664 under VB.NET on 11/9/2012 | Points: 10 | Views : 1560 | Status : [Member] | Replies : 8
Hello..
I have given a label which displays message for textbox when left empty.. When i leave the textbox empty it displays message properlr but the problems comes when i start writing onto the textbox, label is still visible ... Any1 please help as i am stucked up with it since past 3 days and my project is paused... Kindly Help... God Bless U all...!!!




Responses

Posted by: Hariinakoti on: 11/9/2012 [Member] Starter | Points: 25

Up
0
Down
hi,
u can apply label1.enabled=false in pageload and enable true in button click or where u want it.

Thanks & Regards
Hari

Mustafa_9664, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mustafa_9664 on: 11/9/2012 [Member] Starter | Points: 25

Up
0
Down
i want the label to fade out as soon as i start writing onto the textbox... and i have putten up the validations on validating event for every textbox and not on button click..

Mustafa_9664, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 11/9/2012 [Member] Starter | Points: 25

Up
0
Down
how many textbox and labels r u using?

Thanks & Regards
Hari

Mustafa_9664, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mustafa_9664 on: 11/9/2012 [Member] Starter | Points: 25

Up
0
Down
12 textboxes and each assissted with a label and i also have a combobox, a checkbox and two radiobuttons as well in my form... please provide me with the easiest code as i am a beginner... thanku hari..!!!!

Mustafa_9664, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 11/11/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Could you post your code Here?. We will try..


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Mustafa_9664, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mustafa_9664 on: 11/12/2012 [Member] Starter | Points: 25

Up
0
Down
This is my code.. but i want my label to fade as i start writing.. how do we do it..????


Private Sub Registration_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

lbl_vcom_ID.Visible = False
end sub

Private Sub txt_reg_comp_id_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txt_comID.Validating
If txt_comID.Text = Nothing Then
lbl_vcom_ID.Visible = True
lbl_vcom_ID.Text = "Cannot Be Blank"
txt_comID.BackColor = Color.LightYellow
e.Cancel = True
Else
txt_comID.BackColor = Color.White
End If
End Sub

Private Sub txt_comID_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_comID.KeyPress
lbl_vcom_ID.Visible = False
End Sub


Mustafa_9664, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Funda on: 11/14/2012 [Member] Starter | Points: 25

Up
0
Down
You can Achive this in Javascript as simple as ....Validation and Markup should be done in JavaScript/JQuery.....
I have did many validation like this right now I dont have the code :-(.
...

May be this code will be a good Start for U :-)
<script type="text/javascript" language="javascript">

function clearWaterMarkUp() {
if (document.getElementById('txtID').value == "") {
document.getElementById('txtID').value = "Enter Your Name";
document.getElementById('txtID').style.color = "Gray";
}
else if (document.getElementById('txtID').value == "Enter Your Name") {
document.getElementById('txtID').style.color = "Black";
document.getElementById('txtID').value = "";
}

}
</script>


 <asp:TextBox ID="txtID" runat="server" Text="Enter Your Name" style="color:Gray"   onfocus="clearWaterMarkUp();" onblur="clearWaterMarkUp();" ></asp:TextBox>



Mustafa_9664, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 11/14/2012 [Member] Starter | Points: 25

Up
0
Down
Hi ,
try your code in text Box leave Event and Check the Background color line into label control

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Mustafa_9664, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response