Friday, September 7, 2012

Validation Expression for pincode in asp.net

validation expression for pincode checking \d{0,6} 

^\w+$ - text without spaces and numbers

http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)? -
for url

^[0-9]+$ - for numbers

\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*    -  for email
 
 

Confirmation Message While deleting a record from gridview in asp.net

<script type="text/javascript">

function confirmationBox() {
            var r = confirm("Are you sure you want to delete? Click Ok to continue");
            if (r) {
                return true;
            }
            else {
                return false;
            }
        }

</script>


<asp:LinkButton ID="lbtnDelete" runat="server" Text="Delete"
                                        CommandArgument='<%# Eval("ID") %>' CommandName="Delete" OnClientClick="return confirmationBox();"></asp:LinkButton>


// this is for Confirmation Message While deleting a record from gridview or listview, if you say confirm it will delete the record,otherwise if we select cancel it shouldn't delete a record in asp.net

Thursday, August 23, 2012

Date Validation between Startdate and end date using Javascript for ajax Calendar Control

Date Validation between Startdate and end date using Javascript
  function calculate(sender, args) {

            var value1 = document.getElementById('<%=txtSDate.ClientID%>').value.split("/");
            var value2 = document.getElementById('<%=txtEDate.ClientID%>').value.split("/");

            var dttime = new Date(value1[2], value1[1] - 1, value1[0]) //Month is 0-11 in JavaScript
            today = new Date(value2[2], value2[1] - 1, value2[0])

            date1 = new Date(today)
            date1.setHours(0, 0, 0, 0);

            if (dttime > date1) {
                document.getElementById('<%=txtEDate.ClientID%>').value = "";
                alert("From date is greater than to date! ");
            }
            else {

                //Get 1 day in milliseconds
                var oneday = 1000 * 60 * 60 * 24
                //Calculate diff between the two dates, and convert to days
                document.getElementById('<%=txtNoofDays.ClientID%>').value = (today.getTime() - dttime.getTime()) / (oneday);
            }
        }


it will Calculates diff between the two dates, and convert to days

Protected by Copyscape Plagiarism Software