Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here code bellow i just showing whoever text box does empty and user going to click save on that time i just show please enter bellow fields and "" i want those text box atomaticaly appears in red colours" then user can easily find out where he done mistake please send code
C#
if(!string.IsNullOrEmpty(txtmodule.Text) && !string.IsNullOrEmpty(txtparameterType.Text) && (!string.IsNullOrEmpty(txtparameterValue.Text)))
           {
               string APModule = string.Empty;
               string APType = string.Empty;
               string APValue = string.Empty;
               APModule = txtmodule.Text;
               APType = txtparameterType.Text;
               APValue=txtparameterValue.Text;
               bool f_insert = ApplicationParameterBL.Insertdetails(APModule,APType,APValue);
               if (f_insert)
               {
                   ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "alert('Inserted Successfully');", true);
                   FillGrid();
                   btn_AddNew.Visible = true;
                   gridview.Visible = true;
                   pnl_Grid.Visible = true;
                   newtable.Visible = true;
                   txtmodule.Text = "";
                   txtparameterType.Text = "";
                   txtparameterValue.Text = "";
               }
               else
               {

                ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "alert('Failed,Try again');", true);

               }


           }
           else
           {
               string scriptText = "Please Enter The bellow fields,";
               if (string.IsNullOrEmpty(txtmodule.Text))
               {
                   scriptText += "Module:,";
               }
               if (string.IsNullOrEmpty(txtparameterType.Text))
               {
                   scriptText += "ParameterType:,";

               }
               if (string.IsNullOrEmpty(txtparameterValue.Text))
               {
                   scriptText += "Parameter Value:,";
               }
               string[] scriptMessage = scriptText.Split(',');
               string message = string.Empty;
               for (int i = 0; i < scriptMessage.Length; i++)
               {
                   message += scriptMessage[i];
                   message += "\\n";
               }

               ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "alert('" + message + "');", true);
               Pop_up.Show();
           }


       }


my question is""" after textbox validtion fail""" i want those textbox apperers in red colour

please any one can help me
Posted

1 solution

 
Share this answer
 
Comments
Member 10562086 1-Mar-14 7:38am    
<script type="text/javascript">
$(document).ready(function() {
$('#' + '<%= btnSave.ClientID %>').click(function(e) {
var isValid = true;
$('input[type="text"].required').each(function() {
if ($.trim($(this).val()) == '') {
isValid = false;
$(this).css({
"border": "1px solid red",
"background": "#FFCECE"
});
}
else {
$(this).css({
"border": "",
"background": ""
});
}
});
if (isValid == false)
e.preventDefault();
else
alert('Thank you for submitting');
});
});

</script>



this j query show red colour only for type="text" but if i change textmode="mulitiline" its not showing any red colour and its not validated(means for mulitiline text box its not workink),,,please help me sir
Tejas Vaishnav 3-Mar-14 1:27am    
please look around this.. it will showing how to select all textboxes as well as text area using jquery... you need to modified your each loop accordingly so it will work for all textboxes as well as text area

http://stackoverflow.com/questions/825710/how-to-select-all-textareas-and-textboxes-using-jquery
Member 10562086 3-Mar-14 23:59pm    
yes sir i got ,,now its working .thank u so much love u,,,,,,,,,,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900