How to set AM/PM in a textbox using JavaScript? Example

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
    <script src="Scripts/WebForms/jquery-1.7.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#test1").keypress(function (e) {
                debugger
                var regex = ["[0-2]",
                "[0-4]",
                ":",
                "[0-5]",
                "[0-9]",
                "(A|P)",
                "M"],
                string = $(this).val() + String.fromCharCode(e.which),
                b = true;
                for (var i = 0; i < string.length; i++) {
                    if (!new RegExp("^" + regex[i] + "$").test(string[i])) {
                        b = false;
                    }
                }
                return b;
            });
        });
    </script>
</head>
<body>
    <form>
        <p>When?</p>
        <input type="text" id="test1" placeholder="hh:mm(AM|PM)" />
    </form>
</body>
</html>

Share:

How to consume Web Services in C#? Example.

Dictionary < string,
string > dictionary = new Dictionary < string,
string > ();
XElement data = new XElement("create-requests", new XElement("create-request", new XElement("servercode", "dev"), new XElement("projectcode", "your code project")));

HttpWebRequest request = (HttpWebRequest) WebRequest.Create("https://www.google.co.in/");
byte[] bytes;
bytes = System.Text.Encoding.ASCII.GetBytes(data.ToString());
request.ContentType = "text/xml; encoding='utf-8'";
request.ContentLength = bytes.Length;
request.Method = "POST";
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
HttpWebResponse response;
response = (HttpWebResponse) request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK) {
 Stream responseStream = response.GetResponseStream();
 string responseStr = new StreamReader(responseStream).ReadToEnd();
}



Share:

Tuesday, 22 October 2019

How to set AM/PM in a textbox using JavaScript? Example

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
    <script src="Scripts/WebForms/jquery-1.7.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#test1").keypress(function (e) {
                debugger
                var regex = ["[0-2]",
                "[0-4]",
                ":",
                "[0-5]",
                "[0-9]",
                "(A|P)",
                "M"],
                string = $(this).val() + String.fromCharCode(e.which),
                b = true;
                for (var i = 0; i < string.length; i++) {
                    if (!new RegExp("^" + regex[i] + "$").test(string[i])) {
                        b = false;
                    }
                }
                return b;
            });
        });
    </script>
</head>
<body>
    <form>
        <p>When?</p>
        <input type="text" id="test1" placeholder="hh:mm(AM|PM)" />
    </form>
</body>
</html>

Friday, 18 October 2019

How to consume Web Services in C#? Example.

Dictionary < string,
string > dictionary = new Dictionary < string,
string > ();
XElement data = new XElement("create-requests", new XElement("create-request", new XElement("servercode", "dev"), new XElement("projectcode", "your code project")));

HttpWebRequest request = (HttpWebRequest) WebRequest.Create("https://www.google.co.in/");
byte[] bytes;
bytes = System.Text.Encoding.ASCII.GetBytes(data.ToString());
request.ContentType = "text/xml; encoding='utf-8'";
request.ContentLength = bytes.Length;
request.Method = "POST";
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
HttpWebResponse response;
response = (HttpWebResponse) request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK) {
 Stream responseStream = response.GetResponseStream();
 string responseStr = new StreamReader(responseStream).ReadToEnd();
}



Popular

Total Pageviews

Archive