Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in using javascript in cgi-perl

 
monika chaturvedi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello ,i am using javascript in cgi-perl for popup alert and now in pop alert i am doing number checking for user input using regular expression ,
i am try to do this thing by two ways but still is not working .please help me out.
function numcheck()
{
var myForm = document.add_quiz;
var message = '';
var num=/^[0-9]+$/;

if(myForm.marks.value.match(myForm.marks.value.num)) or if(myForm.marks.value != myForm.marks.value.num)
{
alert('Please enter digit');
return(false);
}
else
{
return(true);
}
}
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on advanced Java.

For more information, please read this.

This post has been moved to a more appropriate forum.
 
monika chaturvedi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually i am running this script in internet browser where we genreally dont get error message .as i told you before that i using javascript in cgi-perl .so when i am using javascript for noraml validation like empty text box and retype password is wrong for that javascript is executing perfectly but when i am adding code for this number checking using regular expression in javascript as a third function then my whole code for javascript is not executing and the code which i am using for number checking i already send you.
looking forward for your respone!!
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually i am running this script in internet browser where we genreally dont get error message

"Internet browser" is a generic term, so that doesn't really help. All browsers generate error messages if there are JavaScript problems. In Firefox you can view those in the Tools -> Error Console window. In Internet Explorer these need to be turned on somewhere in the Internet Options; if you don't know how to do that you can use Firefox instead.

as i told you before that i using javascript in cgi-perl

CGI/Perl is a technique for creating HTML/JavaScript on the server. It has no bearing on what happens in the browser.

I'm having a little trouble understanding the remainder of the post; please use punctuation to separate sentences.
 
monika chaturvedi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually there is no need of error message because my script is working fine but where i put alert message it should give the alert for non numeric input but i am not getting that pop of alert .i just want that it should give me popup with alert when non numberic input is entered and when i m entering non numeric input its going to next page didnt checked my validation and not printing my alert which i want.

I hope ,now i make you understand what i exactly want.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually there is no need of error message because my script is working fine but where i put alert message it should give the alert for non numeric input but i am not getting that pop of alert .

So I guess it is not working fine

if(myForm.marks.value.match(myForm.marks.value.num))

if(myForm.marks.value != myForm.marks.value.num)

Both these look suspect. If "myForm.marks.value" is the value of a form field -and thus a String-, what is "myForm.marks.value.num" supposed to be? Strings do not have a "num" attribute.
 
monika chaturvedi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry ,actually that is
if(myForm.marks.value.match(myForm.num.value))
then do this
.............

i did like this in my actual program
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd put in alert statements that show you the actual values of the fields you're comparing. Using a JavaScript debugger may also be helpful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic