Jump to content

Form Validations in HTML

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
Bbob

Bbob

    Newbie

  • Members
  • Pip
  • 2 posts
Hi

Im new at programming and I need a little help


What Im try to do is

1. To create an HTML file that can validate forms WITHOUT the use a server. (is this possible?)

2. The validation of forms will be like the ones from registering a Yahoo email account (When you focus on another textbox there is an alert on the side of the textbox if it has an invalid value) - What do I need to study to do this without using a server?


Basically what I want is an html page that checks if the textbox has any values in it. If it doesnt have any, it will display an alert without the use of a new window. (Just like the registration page here)

Thank you in advance.

#2
throese

throese

    Learning Programmer

  • Members
  • PipPipPip
  • 38 posts
I do not believe that it's possible to do that with only HTML. I'm sure that you have to use either Javascript and/or PHP and a little CSS (Cascading Style Sheets), to keep things organized. You can look at JS (Javascript) and PHP (PHP: Hypertext Preprocessor).

CSS Tutorial
JavaScript Tutorial
http://www.w3schools.com/php/

Try the above 3 links to learn about the recommended languages to get the results you want.

Also, to use PHP, you'll need either:

WAMP - PHP Apache MySQL avec WampServer 2 : installation PHP MySQL Apache

XAMPP - apache friends - xampp Pick the download that goes with the operating system (OS) you have/use.

Windows
Mac
Linux
Unix

I hope that I helped you to the best of my abilities.

#3
ferovac

ferovac

    Learning Programmer

  • Members
  • PipPipPip
  • 84 posts

Bbob said:

Basically what I want is an html page that checks if the textbox has any values in it. If it doesnt have any, it will display an alert without the use of a new window. (Just like the registration page here).

it can be done all you need is some javascript that will go of on button press, will check if there is anything in the textbox and echo alert

simple example:

<html>
<body>
<div>
<form action="" method="post">
<input type="textbox" id="textbox"/>
<input type="button" value="Submmit" onclick="check()"/></div>

<div><script type="text/javascript">

	function check(){
		var str = document.getElementById('textbox').value;
		if(str.length==0)
		alert("Alert textbox is empty!");
		else alert(str);
	}

</script></div>

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

just copy it in a txt file name it something.html save and double click on it

#4
Bbob

Bbob

    Newbie

  • Members
  • Pip
  • 2 posts
Thanks for the replies.

@throese
I managed to do read the links provided and it was very helpful. I also came across AJAX, which I think is what Im looking for.

But there is something that confuses me, in this link Tryit Editor v1.4 there is an ajax_info.txt which I dont know where its from. Another thing I dont understand is how the coder managed to position the new text.


@ferovac

Thats almost what Im looking for except I dont want to have an alert box. I want the alert to appear beside the textbox.

Something like this, which I think uses AJAX
Posted Image

#5
ferovac

ferovac

    Learning Programmer

  • Members
  • PipPipPip
  • 84 posts
yes you could do it with ajax but then php would do the check, or you could check it with javascript and then just make javascript append a html element into page the javascript function name is append .... now google

#6
Guest_johnny.dacu_*

Guest_johnny.dacu_*
  • Guests
Javascript validation has some problems. It's not safe. Any user with some experience can bypass validation. Ajax/server side is the smart solution.

#7
ferovac

ferovac

    Learning Programmer

  • Members
  • PipPipPip
  • 84 posts

johnny.dacu said:

Javascript validation has some problems. It's not safe. Any user with some experience can bypass validation. Ajax/server side is the smart solution.

oh your way off did you read the whole thread, all he is trying to do is check if there is anything in the form, which is useful to lower the traffic, he will ofcourse check the input on the server side once it gets there