Current location: Hot Scripts Forums » General Web Coding » JavaScript » Help Me Please!!


Help Me Please!!

Reply
  #1 (permalink)  
Old 11-21-03, 09:40 AM
tcooper tcooper is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Question Help Me Please!!

I am new to this so someone PLEASE HELP ME!!

I have a php form which I am trying to check. My code is shown below (only the piece which is questionable). This code works, however, what I want is the line I currently have commented off. If I comment off the first "if" statement (the one I don't want) I get an error saying "Object Expected". What am I doing wrong? Why will it work for the first if statement but not the second?


<script language="JavaScript" type="text/javascript">
function checkform (form1)
{if (form1.txtJobNo.value == "C"){
//{if (preg_match("/[A-a]{2,2}[0-9]{8,8}/", form1.$jobno)){
alert ("Please enter a valid job number");
return False;}
}
Reply With Quote
  #2 (permalink)  
Old 11-28-03, 02:33 PM
melsana melsana is offline
Newbie Coder
 
Join Date: Nov 2003
Location: MD
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
The problem is you are getting your javascript and php confused.

You are writing a javascript function there NOT php. preg_match() is php NOT javascript.

If you want to use regular expressions in javascript, this "should" work.
Code:
<script language="JavaScript" type="text/javascript">
function checkform (form1) {
  var re = /[A-a]{2,2}[0-9]{8,8}/g; 
  if (form1.txtJobNo.match(re)) {
    alert ("Please enter a valid job number");
    return false;
  }
}

Last edited by melsana; 11-28-03 at 02:36 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 11:25 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.