i am using netbean to develop a registration form.
As this i want to know what is the coding to check input of text, integer, email , so i can restrict what they input..hope some 1 help me =)

7 Years
Discussion Span
Last Post by dean8710

show what code you have for the input, so that the javascript demons can see what requirement of validation there is
else could write you 10000s of if() statements and none of them are appropriate

the answer probably won't come from me,
javascript -hopeless,
but somebody has the signature "half the solution is defining the problem"


Here are two functions for email and numbers. I don't know what you want to check for with text. If it's free form text there's really no check. Did you just want characters and no numbers?

function validate() {
	if (!isEmail(document.getElementById("emailAddr").value)) {
		alert("Bad email address");
	if (!isNumeric(document.getElementById("myNumber").value, false)) {
	    alert("Bad number");
	alert("Good Job!);
function isEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
		return (true)
	return (false)
function isNumeric(sText, decimalAllowed) {
    if (sText.length == 0) return false;
    var validChars = "";
	if (decimalAllowed) {
		validChars = "0123456789.";
	} else {
		validChars = "0123456789";
    var isNumber = true;
    var charA;
	var decimalCount = 0;
    for (i = 0; i < sText.length && isNumber == true && decimalCount < 2; i++) {
		charA = sText.charAt(i); 
		if (charA == ".") { 
			decimalCount += 1;
		if (validChars.indexOf(charA) == -1) {
			isNumber = false;
	return isNumber;
<form action="#" name="form1" id="form1" method="GET">
	E-mail Address:<br />
	<input type="text" name="emailAddr" id="emailAddr" /><br />
	Enter Number:<br />
	<input type="text" name="myNumber" id="myNumber" /><br />
	<input type="button" value="Submit" id="button" onClick="validate()" />
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.