473,395 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Regular Expressions

Can you plis help me in identifying the error in the following code......



[HTML]<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>First Name</title>
<script type="text/javascript">
//function RegExp()


function validate()
{
var fname = document.getElementById("fname").value
var lname = document.getElementById("lname").value
var omang = document.getElementById("omang").value
var chief = document.getElementById("chief").value
var address = document.getElementById("address").value
var cellNumber = document.getElementById("cell").value
var regExp = (/[A-Za-z0-9]+\@[A-Za-z0-9]+(\.[A-Za-z0-9])*\.[A-Za-z]/)
var email = document.getElementById("email").value
var reg= (/[A-Za-z]\*/)
var c = (/[0-9]*/)
submitOK = "true"

if(fname <reg)
{
alert("Enter a valid first name")
submitOK = "false"
}
else if(lname<reg)
{
alert("Enter a valid surname")
submitOK = "false"
}
else if (omang.length!=9||isNaN(omang))
{
alert ("Please enter a valid ID Number")
submitOK = "false"
}
else if(chief<reg)
{
alert("Enter a valid Chief's name")
submitOK = "false"
}
else if(address<reg)
{
alert("Enter a valid Address")
submitOK = "false"
}

else if(cellNumber<c && cellNumber.length!=8)
{
alert ("Please enter a cell Number")
submitOK = "false"
}

else if(email && regExp==-1)
{
alert ("Please enter a valid e-mail address")
submitOK = "false"
}

if (submitOK=="false")

{
return false
}
}

</script>
<script>
function Confirm()
{
var agree = confirm ("Are you sure you want to resert");
if (agree)
{
return true
}
else{
return false
}
}
var newWindow;
</script>
<script type ="text/javascript">
function openWindow()
{
newWindow=window.open("","myWindow", "toolbar=0, menubar=0");
newWindow.document.write("<h1> This is Heading h1 for this Window</>");
}

</script>
</head>

<body bgcolor =#FFFFFF>

<form method="POST" action="--WEBBOT-SELF--" onsubmit = "return validate ()">
<!--webbot bot="SaveResults" U-File="D:\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;</p>
<div align="center">
<table border="1" width="80%" id="table1" bordercolor="#000000">
<tr>
<td width="39%" bordercolor="#FFFFFF" bgcolor="#C0C0C0" align="left">
<b>First Name</b></td>
<td colspan="2" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><input type="text" name="T1" size="20" id="fname"></td>
</tr>
<tr>
<td width="39%" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><b>Surname</b></td>
<td colspan="2" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><input type="text" name="T2" size="20" id="lname"></td>
</tr>
<tr>
<td width="39%" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><b>Omang</b></td>
<td colspan="2" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><input type="text" name="T3" size="20" id="omang"></td>
</tr>
<tr>
<td width="39%" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><b>Chief</b></td>
<td colspan="2" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><input type="text" name="T4" size="20" id="chief"></td>
</tr>
<tr>
<td width="39%" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><b>Age</b></td>
<td colspan="2" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><select size="1" name="D1" id="age">
<option>Select your age</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>

</select ></td>
</tr>
<tr>
<td width="39%" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><b>Address</b></td>
<td colspan="2" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><input type="text" name="T5" size="20" id="address"></td>
</tr>
<tr>
<td width="39%" bgcolor="#C0C0C0" bordercolor="#FFFFFF" height="25" align="left"><b>Cell Number</b></td>
<td colspan="2" bgcolor="#C0C0C0" bordercolor="#FFFFFF" height="25" align="left"><input type="text" name="T6" size="20" id="cell"></td>
</tr>
<tr>
<td width="39%" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><b>Email Address</b></td>
<td colspan="2" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><input type="text" name="T7" size="20" id="email"></td>
</tr>
<tr>
<td width="39%" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left"><b>Gender</b></td>
<td width="23%" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left">
<input type="radio" value="V3" checked name="R1"><b>Male</b></td>
<td width="15%" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left">
<input type="radio" name="R1" value="V4"><b>Female</b></td>
</tr>
<tr>
<td colspan="3" bgcolor="#C0C0C0" bordercolor="#FFFFFF" align="left">
<p align="center">&nbsp;
<button name="B4" style="width: 56; height: 26" onclick= "openWindow()">Help</button>&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="Submit" name="B1">&nbsp;&nbsp;
<input type="reset" value="Reset" name="B2" onclick="return Confirm()"></td>
</tr>
</table>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>

</body>

</html>[/HTML]
Mar 19 '07 #1
1 1092
acoder
16,027 Expert Mod 8TB
Use match to match the RegExp with the string values. You are using "less than" (<) which is not going to work.

See this link.
Mar 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Michael McGarry | last post by:
Hi, I am horrible with Regular Expressions, can anyone recommend a book on it? Also I am trying to parse the following string to extract the number after load average. ".... load average:...
1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
2
by: Sehboo | last post by:
Hi, I have several regular expressions that I need to run against documents. Is it possible to combine several expressions in one expression in Regex object. So that it is faster, or will I...
4
by: Együd Csaba | last post by:
Hi All, I'd like to "compress" the following two filter expressions into one - assuming that it makes sense regarding query execution performance. .... where (adate LIKE "2004.01.10 __:30" or...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
3
by: a | last post by:
I'm a newbie needing to use some Regular Expressions in PHP. Can I safely use the results of my tests using 'The Regex Coach' (http://www.weitz.de/regex-coach/index.html) Are the Regular...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
1
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find...
13
by: Wiseman | last post by:
I'm kind of disappointed with the re regular expressions module. In particular, the lack of support for recursion ( (?R) or (?n) ) is a major drawback to me. There are so many great things that can...
12
by: FAQEditor | last post by:
Anybody have any URL's to tutorials and/or references for Regular Expressions? The four I have so far are: http://docs.sun.com/source/816-6408-10/regexp.htm...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.