How to check form validation by javascript

Hello
Now, I am ready to show how to check form validation by using javascript. Its a primary stage of a javascript prorgammer. Lets go-

<!DOCTYPE html>
<html>
<head>
<title>Learn JavaScrtipt</title>

<script>
/*

var x = window.confirm(“Are you sure to delete this?”);

if(x){

window.alert(“Your data is goting to delete.”);

}else{

window.location = “https://tisuchi.wordpress.com&#8221;;
}

*/

/*
function emailchk(){
var x = document.aa.bb.value;

if(x.indexOf(“@”) == -1){
alert(“Please entair a valid email address”);
}
document.aa.bb.focus();
}
*/
function validation(){

if(document.formname.name.value==””)
{
alert (“Please enter User Name”)
document.formname.name.focus();
return false;
}
}
</script>
</head>

<body>

<form name=”formname” method=”POST” onsubmit=”return validation()”>
<input type=”text” name=”name” value=”” placeholder=”Type your name” ><br/>
<input type=”text” name=”email” value=”” placeholder=”Type your email” ><br/>
<input type=”submit” name=”email” value=”Submit Now”>
</form>
</body>
</html>

Save this file and run it. It will check if any field will be blank. Thanks for reading.

Advertisements

What is indexOf() in Javascript

Consider the previous tutorial for this tutorial.

If you enter an email address without the @, you’ll get an alert asking you to re-enter the data. Now question is, what is:x.indexOf(@)==-1? This is a method that JavaScript can search every character within a string and look for what we want. If it finds it will return the position of the char within the string. If it doesn’t, it will return -1. Therefore,x.indexOf("@")==-1 basically means: “if the string doesn’t include @, then:

 

Thanks for reading…

Check valid email address by Javascript

Hello Friends,
Hope you are fine. I am fine. Today, I am showing how to check valid email address by using javascript. Its a very primary label work for javascript programmer. This task for javascript beginner. Lets start the work.

<!DOCTYPE html>
<html>
<head>
<title>Learn JavaScrtipt</title>

<script>

function emailchk(){

var x = document.aa.bb.value;

if(x.indexOf(“@”) == -1){
alert(“Please entair a valid email address”);
}

}

</script>
</head>

<body>

<form name=”aa”>

<input type=”text” name=”bb” value=”” placeholder=”Type your email” onBlur=”emailchk()”>
<input type=”text” name=”cc” value=”” placeholder=”Type your phone” onClick=””>

</form>
</body>
</html>

This is the code for all the work. Now, save your fine and run this file. Well, now, your file is ready to use. Just blur your text field and you will see some interactive work by javascript.

Thanks for reading.

 

Show value of form element by Javascript

Hello Friends,
Now I am showing how to show value of form element by javascript. Its a very simple example for beganner. Lets start.

<form name=”aa”>

<input type=”text” size=”10″ value=”” name=”bb”><br> <input type=”button” value=”Click Here”onclick=”alert(document.aa.bb.value)”>

</form>

Here it is important that, we gave the names to the form and the element. So JavaScript can gain access to them.

Thanks for reading….

Fatal error: Call to undefined function base_url() in Codeigniter

Hey Guys.
How are you? Hope you are fine. Now, I am going to show how to recover a Fatal Error in codeigniter.

In codeigniter, sometime you will face some fatal error like the below-

Fatal error: Call to undefined function base_url()

If you face that kind of fatal error, then you have to understand this is for base_ulr() function only, nothing else.
You know, base_url() is function is based on url at codeigniter. That’s why, you have to mentioned the url in your controller or autoload.php file. I suggest to put url in your autoload file. Thats why you have to go to your codeigniter directory and open /system/application/config/autoload.php file. Now, find out the $autoload[‘helper’] = array(); line. It can be 54 no line. (Currently I am using the CI version 1.7.3).

Continue reading