RSS

Monthly Archives: May 2018

List of HTTP status codes – HTTP Error Code

1xx: Information

Message: Description:
100 Continue The server has received the request headers, and the client should proceed to send the request body
101 Switching Protocols The requester has asked the server to switch protocols
103 Checkpoint Used in the resumable requests proposal to resume aborted PUT or POST requests

2xx: Successful

Message: Description:
200 OK The request is OK (this is the standard response for successful HTTP requests)
201 Created The request has been fulfilled, and a new resource is created
202 Accepted The request has been accepted for processing, but the processing has not been completed
203 Non-Authoritative Information The request has been successfully processed, but is returning information that may be from another source
204 No Content The request has been successfully processed, but is not returning any content
205 Reset Content The request has been successfully processed, but is not returning any content, and requires that the requester reset the document view
206 Partial Content The server is delivering only part of the resource due to a range header sent by the client

3xx: Redirection

Message: Description:
300 Multiple Choices A link list. The user can select a link and go to that location. Maximum five addresses
301 Moved Permanently The requested page has moved to a new URL
302 Found The requested page has moved temporarily to a new URL
303 See Other The requested page can be found under a different URL
304 Not Modified Indicates the requested page has not been modified since last requested
306 Switch Proxy No longer used
307 Temporary Redirect The requested page has moved temporarily to a new URL
308 Resume Incomplete Used in the resumable requests proposal to resume aborted PUT or POST requests

4xx: Client Error

Message: Description:
400 Bad Request The request cannot be fulfilled due to bad syntax
401 Unauthorized The request was a legal request, but the server is refusing to respond to it. For use when authentication is possible but has failed or not yet been provided
402 Payment Required Reserved for future use
403 Forbidden The request was a legal request, but the server is refusing to respond to it
404 Not Found The requested page could not be found but may be available again in the future
405 Method Not Allowed A request was made of a page using a request method not supported by that page
406 Not Acceptable The server can only generate a response that is not accepted by the client
407 Proxy Authentication Required The client must first authenticate itself with the proxy
408 Request Timeout The server timed out waiting for the request
409 Conflict The request could not be completed because of a conflict in the request
410 Gone The requested page is no longer available
411 Length Required The “Content-Length” is not defined. The server will not accept the request without it
412 Precondition Failed The precondition given in the request evaluated to false by the server
413 Request Entity Too Large The server will not accept the request, because the request entity is too large
414 Request-URI Too Long The server will not accept the request, because the URL is too long. Occurs when you convert a POST request to a GET request with a long query information
415 Unsupported Media Type The server will not accept the request, because the media type is not supported
416 Requested Range Not Satisfiable The client has asked for a portion of the file, but the server cannot supply that portion
417 Expectation Failed The server cannot meet the requirements of the Expect request-header field

5xx: Server Error

Message: Description:
500 Internal Server Error A generic error message, given when no more specific message is suitable
501 Not Implemented The server either does not recognize the request method, or it lacks the ability to fulfill the request
502 Bad Gateway The server was acting as a gateway or proxy and received an invalid response from the upstream server
503 Service Unavailable The server is currently unavailable (overloaded or down)
504 Gateway Timeout The server was acting as a gateway or proxy and did not receive a timely response from the upstream server
505 HTTP Version Not Supported The server does not support the HTTP protocol version used in the request
511 Network Authentication Required The client needs to authenticate to gain network access
Advertisements
 
Comments Off on List of HTTP status codes – HTTP Error Code

Posted by on May 30, 2018 in HTML5, Programming, Website Administration

 

Validating Form Input in JavaScript

Validating Form Input

When you submit a form to a CGI program that resides on the server, it is usually programmed to do its own check for errors. If it finds any it sends the page back to the reader who then has to re-enter some data, before submitting again. A JavaScript check is useful because it stops the form from being submitted if there is a problem, saving lots of time for your readers.

The CGI script is still more reliable, as it always works regardless of whether JavaScript is enabled on the client-side or not; but having this extra safety barrier is a nice thing to have in place. It makes your page much more user-friendly, and takes out the frustration of having to fill out the same form repeatedly. It’s also very precise, as you can point out the exact field where there’s a problem.

Implementing the Check

We’re going to be checking the form using a function, which will be activated by the form’s submit event — therefore, using the onSubmit handler. Add an attribute like this to the form you wish to validate:

<form action="script.cgi" onSubmit="return checkform()">

Where checkForm is the name of the function we’re about to create. If you’ve learnt your functions properly, you should be able to guess that our function will return a Boolean value — either true or false. Submit‘s default action is to submit the data, but if you give onSubmit a value of return false, it will not be submitted; just like how we can stop a link from being followed. Of course, if there are no problems, the function call will be replaced by true and the data will be submitted. Simple…

It’s impossible for me to give you a definitive validation script, as every form is different, with a different structure and different values to check for. That said, it is possible to give you the basic layout of a script, which you can then customise to the needs of your form.

A general script looks like this:

function checkform()
{
	if (value of first field is or isn't something)
	{
		// something is wrong
		alert('There is a problem with the first field');
		return false;
	}
	else if (value of next field is or isn't something)
	{
		// something else is wrong
		alert('There is a problem with...');
		return false;
	}
	// If the script gets this far through all of your fields
	// without problems, it's ok and you can submit the form

	return true;
}

If your form is quite complex your script will grow proportionally longer too, but the fundamentals will stay the same in every instance — you go through each field with if and else statements, checking the inputted values to make sure they’re not blank. As each field passes the test your script moves down to the next.

If there is a problem with a field, the script will return false at that point and stop working, never reaching the final return true command unless there are no problems at all. You should of course tailor the error messages to point out which field has the problem, and maybe offering solutions to common mistakes.

Accessing Values

Having read the Objects and Properties page, you should now know how to find out the values of form elements through the DOM. We’re going to be using the name notation instead of using numbered indexes to access the elements, so that you are free to move around the fields on your page without having to rewrite parts of your script every time. A sample, and simple, form may look like this:

<form name="feedback" action="script.cgi" method="post" onSubmit="return checkform()">
<input type="text" name="name">
<input type="text" name="email">
<textarea name="comments"></textarea>
</form>

Validating this form would be considerably simpler than one containing radio buttons or select boxes, but any form element can be accessed. Below are the ways to get the value from all types of form elements. In all cases, the form is called feedback and the element is called field.

Text Boxes, <textarea>s and hiddens

These are the easiest elements to access. The code is simply

document.feedback.field.value

You’ll usually be checking if this value is empty, i.e.

if (document.feedback.field.value == '') {
	return false;
}

That’s checking the value’s equality with a null String (two single quotes with nothing between them). When you are asking a reader for their email address, you can use a simple » address validation function to make sure the address has a valid structure.

Select Boxes

Select boxes are a little trickier. Each option in a drop-down box is indexed in the array options[], starting as always with 0. You then get the value of the element at this index. It’s like this:

document.feedback.field.options
[document.feedback.field.selectedIndex].value

You can also change the selected index through JavaScript. To set it to the first option, execute this:

document.feedback.field.selectedIndex = 0;

Check Boxes

Checkboxes behave differently to other elements — their value is always on. Instead, you have to check if their Boolean checked value is true or, in this case, false.

if (!document.feedback.field.checked) {
	// box is not checked
	return false;
}

Naturally, to check a box, do this

document.feedback.field.checked = true;

Radio Buttons

Annoyingly, there is no simple way to check which radio button out of a group is selected — you have to check through each element, linked with Boolean AND operators . Usually you’ll just want to check if none of them have been selected, as in this example:

if (!document.feedback.field[0].checked &&
!document.feedback.field[1].checked &&
!document.feedback.field[2].checked) {
	// no radio button is selected
	return false;
}

You can check a radio button in the same way as a checkbox.

 

 

 

Source: http://www.yourhtmlsource.com/javascript/formvalidation.html

 

 
Comments Off on Validating Form Input in JavaScript

Posted by on May 30, 2018 in Javascript

 

JS Charting

jsFiddle for Drill-down graph
http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/drilldown/async/

Parameters based Graph generator: https://my.infocaptor.com/free_data_visualization.php
Dashboard Graph: http://bl.ocks.org/NPashaP/96447623ef4d342ee09b

Free js charting component:  http://code.highcharts.com/

asp.net drill-down
http://www.intertech.com/Blog/asp-net-chart-drill-down/
http://www.flex888.com/894/flex-drill-down-charts.html

d3.js. See the gallery:

https://github.com/mbostock/d3/wiki/Gallery

Drill down demos or examples:
•http://mbostock.github.com/d3/talk/20111116/bar-hierarchy.html
•http://mbostock.github.com/d3/talk/20111018/treemap.html
•http://mbostock.github.com/d3/talk/20111018/partition.html
•http://bost.ocks.org/mike/miserables/
•http://www.jasondavies.com/coffee-wheel/
•http://thepowerrank.com/visual/NCAA_Tournament_Predictions
•http://square.github.com/crossfilter/
•http://windhistory.com/map.html#4.00/36.00/-95.00 / http://windhistory.com/station.html?KMKT
•http://trends.truliablog.com/vis/tru247/
•http://trends.truliablog.com/vis/metro-movers/
•http://marcinignac.com/projects/open-budget/viz/index.html
•http://bl.ocks.org/3630001
•http://bl.ocks.org/1346395
•http://bl.ocks.org/1314483
•http://slodge.com/teach/
•http://tympanus.net/Tutorials/MultipleAreaChartsD3/
•http://bl.ocks.org/3287802

 

 
Comments Off on JS Charting

Posted by on May 30, 2018 in Charting

 

Sending email in ASP.NET with email validation

//MailMessage tipsMail = new MailMessage();
//tipsMail.To.Add(email);
//tipsMail.From = new MailAddress(System.Configuration.ConfigurationManager.AppSettings[“fromAddress”].ToString());
//tipsMail.From = new MailAddress(“PMTips@mosaiquegroup.com”);
//tipsMail.Subject = “Project Management Tips from Mosaique”;
//tipsMail.Body = tipsMessage;
//tipsMail.IsBodyHtml = true;
// tipsMail.To.Add(System.Configuration.ConfigurationManager.AppSettings[“adminEmail”].ToString());
// tipsMail.To.Add(System.Configuration.ConfigurationManager.AppSettings[“adminEmail2”].ToString());
//tipsMail.To.Add(System.Configuration.ConfigurationManager.AppSettings[“adminEmail3”].ToString());
// tipsMail.To.Add(“javedarifkhan1@gmail.com”);

// SmtpClient smtp2 = new SmtpClient(“localhost”);
//// NetworkCredential credential2 = new NetworkCredential(System.Configuration.ConfigurationManager.AppSettings[“smtpUser”], System.Configuration.ConfigurationManager.AppSettings[“smtpPass”]);
// NetworkCredential credential2 = new NetworkCredential(“smtpUser”, “XXXXX”);
// smtp2.Credentials = credential2;
// smtp2.EnableSsl = true;
// smtp2.Send(tipsMail);

//MailMessage msg = new MailMessage();
//System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
//msg.From = new MailAddress(“smtpUser@domain.com”);
//msg.To.Add(email);
//msg.IsBodyHtml = true;
//msg.Body = tipsMessage;
//client.Host = “localhost”;
//System.Net.NetworkCredential basicauthenticationinfo = new System.Net.NetworkCredential(“Username”, “password”);
////client.Port = int.Parse(“587”);
//client.EnableSsl = true;
//client.UseDefaultCredentials = false;
//client.Credentials = basicauthenticationinfo;
//client.DeliveryMethod = SmtpDeliveryMethod.Network;
//client.Send(msg);

//MailMessage tipsMail = new MailMessage();
//tipsMail.From = “user@domain.com”;
//tipsMail.To.Add(email);
//System.Net.Mail.SmtpClient mail = new System.Net.Mail.SmtpClient();
//tipsMail.Body = tipsMessage;
//tipsMail.To.Add(“javedarifkhan1@gmail.com”);
//tipsMail.IsBodyHtml = true;

//SmtpClient smtp = new SmtpClient(“localhost”);
// smtp.Credentials = credential;
//smtp.EnableSsl = true;
//smtp.Send(tipsMail);

//////////// USING GOOGLE SMTP SERVER //////////////////
//// smtp.Host = “smtp.gmail.com”; // smtp.UseDefaultCredentials = true;
//SmtpClient smtp = new SmtpClient();
//smtp.Host = System.Configuration.ConfigurationManager.AppSettings[“smtpHost”].ToString();
//smtp.EnableSsl = true;
//NetworkCredential NetworkCred = new NetworkCredential(System.Configuration.ConfigurationManager.AppSettings[“smtpGUser”].ToString(), System.Configuration.ConfigurationManager.AppSettings[“smtpGPass”].ToString());
//smtp.Credentials = NetworkCred;
//smtp.Port = int.Parse(System.Configuration.ConfigurationManager.AppSettings[“smtpGPort”].ToString());
//smtp.Send(tipsMail);

 
Comments Off on Sending email in ASP.NET with email validation

Posted by on May 30, 2018 in Uncategorized

 
 
%d bloggers like this: