...

View Full Version : Validations needed



shahwali
06-10-2007, 10:04 PM
Hello Programmers,
Please help me write the validations for the given code
(Category Name & description should not be empty).

Thanks

<html>
<title>form</title>
<head>
<body>
Category Name <input type="text" name="myform" method="post"><br>
Category Description <textarea rows="10" cols="30"> </textarea>
<input type="submit" value="Submit">
<input type="button" value="Cancel">
</body>
</html>

shahwali
06-10-2007, 10:11 PM
Hello Programmers,
Please help me write the validations for the given code
(Category Name & description should not be empty).

Thanks

<html>
<title>form</title>
<head>
<body>
Category Name <input type="text" name="myform" method="post"><br>
Category Description <textarea rows="10" cols="30"> </textarea>
<input type="submit" value="Submit">
<input type="button" value="Cancel">
</body>
</html>
somebody help me please :(

rwedge
06-10-2007, 10:32 PM
You should try searching (http://www.google.com/search?q=site%3Acodingforums.com+validate+empty+field&qfront=validate+empty+field) the forums for an answer, it is a common question.
If you have trouble putting it together ask for more help.

shahwali
06-10-2007, 10:35 PM
I've been searching it since the time I posted the question.
But couldnt find the code :(
and by the way, thanks for showing interest, I really appreciate it.

rwedge
06-10-2007, 10:59 PM
Here's an example:
<html>
<title>form</title>
<script type="text/javascript">
function validateForm(frm){
if (frm.txt.value.search(/\w/) == -1) {
alert('Category Name Must Have A Value');
frm.txt.focus();
return false;
}
else if (frm.txtarea.value.search(/\w/) == -1) {
alert('Category Description Must Have A Value');
frm.txtarea.focus();
return false;
}
else { return true; }
}
</script>
<head>
<body>

<form name="myform" id="myform" method="post" action="" enctype="multipart/form-data" onsubmit="return validateForm(this)">
Category Name <input type="text" name="txt" id="txt" value=""><br>
Category Description <textarea name="txtarea" id="txtarea" rows="10" cols="30"></textarea>
<input type="submit" value="Submit">
<input type="reset" value="Cancel">
</form>

</body>
</html>

shahwali
06-11-2007, 03:29 AM
Thank You so very much :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum