Click here to Skip to main content
15,881,516 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I dont want that empty details...and when i click submit button with empty form then it shows all alerts one by one...I want only one alert single time...any body please help me...




Thanks in advance...
Posted
Comments
ArunRajendra 4-Nov-14 1:46am    
Can you post you code for save?
syed shanu 4-Nov-14 1:48am    
In your javascript function first you need to check for textbox not empty.if its empty display alert and return false.if its not empty then continue with other validation.
You can also your ASP.Net validation controls
Sinisa Hajnal 4-Nov-14 1:58am    
You have to return false from your function and have click handler like this: onclick="return your_function();" so it returns false. This will prevent postback.

1 solution

Use the script correctly,
Try this script, for each textbox,dropdown and other controls.
JavaScript
<script language="javascript" type="text/javascript">
function  Validate() {          
if (document.getElementById('<%= dropdownid.ClientID%>').value == "Select") {
alert("Please Select Details!");
document.getElementById('<%= dropdownid.ClientID%>').focus();
return false;
}

if (document.getElementById('<%=textboxId.ClientID %>').value == "") {
alert("Please Enter Your Text point!");
document.getElementById('<%=textboxId.ClientID %>').focus();
return false;
}

}
</script>

call the validate function in your submit button,
for example,
ASP.NET
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick ="return Validate();" />
 
Share this answer
 
v4

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