Share on Google+Share on Google+

sarika
check where is error
1 Answer(s)      8 years ago
Posted in : JSP-Interview Questions

Ads

View Answers

October 1, 2008 at 12:45 PM


Hi friend,


We test and run the program having error of it always come in the "else"
condition due to white space problem.
This problem remove to use trim function in javascript.

function trim(value) {
var temp = value;
var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
var obj = / /g;
while (temp.match(obj)) { temp = temp.replace(obj, " "); }
return temp;
}

correct code :

<html>
<head>
<title>javscsript program</title>
<script type="text/javascript" language="javascript">
function trim(value) {
var temp = value;
var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
var obj = / /g;
while (temp.match(obj)) { temp = temp.replace(obj, " "); }
return temp;
}
function palindrome()
{
var string=document.f.text.value;
document.f.reverse.value=reverse(string);

alert(string);
alert(reverse(string));

if(trim(string) == trim(reverse(string)))
{
alert("this is djfksjfja palindrome");
}
else
{
alert("this is not a palindrome");
}
}
function reverse(ss)
{
var len=ss.length;
var rev=" ";
for(var i=len; i>=0; i--)
{
var rev= rev+ss.charAt(i);
}
return rev;
}

</script>
</head>
<body>
<form name="f">
Enter string to be Reversed : <input type="text" name="text"><br>
<input type="button" onClick="palindrome(); " value="submit "><br>
Reversed String is : <input type="text" name="reverse">
</form>
</body>

</html>

If you have any more problem then explain in details.

Thanks









Related Tutorials/Questions & Answers:
check where is error - JSP-Interview Questions
check where is error  hi deepak i have made a program in javascript but it is not working properly will u plz tell me where is error in my program... is :   Hi friend, We test and run the program having error
check
updated"); will the above code check if the user has entered value for empcode
Advertisements
plz check my codings are correct or not...There is an error..i cant find it..
plz check my codings are correct or not...There is an error..i cant find it..  import java.util.Scanner; public class Student { private String indexNo; private String gender; private char initial; private int mark1
i got illegal start of expression error , plese tell me the mistake where i did...
i got illegal start of expression error , plese tell me the mistake where i did...   import org.springframework.context.*; import java.util.*; public class MyListener implements ApplicationListener { public static void main
Mysql Check
Mysql Check       Mysql Check is used to check the existence of table in the database. Understand with Example The Tutorial illustrate an example from 'Mysql Check
Where clause
Where clause  I have doubt in Where clause .. i got a Employid from user and check the id and display the details of that id what can i do?   The WHERE clause is used to filter records.It is used to extract only those
check for errors
check for errors  How can I check for errors
password check
password check  how to check sighup passowrd and login password
check anagram
check anagram   compare two input is anagram or not but input contains million words
error
error  java.lang.unsupportedclassversionerror:bad major version at offset 6 how to solve this????   Hi, Please check the version of framework used and also the JDK version. This type error also comes when java file
check null exception java
this error. The only way to handle this error is validation. You need to check...check null exception java  check null exception java - How to check the null exception on Java?   The null pointer exception in java occurs
XML Error Checking and Locating
XML Error Checking and Locating       In this section, you will learn how to check and locate an error in the XML document and error position.  Description of program: The following
Where to update the Hibernate tools?
Where to update the Hibernate tools?  Hi, What is the url to to update the hibernate tool in eclipse? Thanks   Hi, Hi if you are using the hibernate tool you can update it. Check Check the tutorial Hibernate tools
error
error  while iam compiling iam getting expected error
Error-
Error-   Hello, I would like to know about XSD file. I try to print XML file but I am getting error SAXException-- says Content is not allowed in prolog. Please help me
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  i have 404 error in my program plz tell me yhe solution about
error
/ServletUserEnquiryForm.shtml getting an error given below SQLException caught: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error please suggest
Error
Error  I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me error as 'Unknown Runtime Error'. This error come only in IE browser, but in other brower
check youtube iframe code
check youtube iframe code  I have a piece of code that checks...: //Check Embed Code $embedCode = $postData['embedCode... { $mainframe->enqueueMessage(JText::_('EMBED CODE ERROR
error
error
error
error  When I deploye the example I have this message cannot Deploy HelloWorld Deployment Error for module: HelloWorld: Error occurred during deployment: Exception while deploying the app [HelloWorld
where to start - Java Beginners
where to start  Myself being a java beginner want to know wat... from http://www.roseindia.net/java/learn-java-in-a-day/index.shtml Check... You can master Java in a week. Please check our section http
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
How to check a checkbox - Struts
How to check a checkbox  Hello Community, How can i check a checkbox defined with tags. with plain html, the tag checks the box. with the other tags i am getting an error that the property "checked" is not defined. Can someone
CRC(cyclic redundancy check) - UML
CRC(cyclic redundancy check)  write a program that accepts a data sequence , generates a fcs (using a known divisor) and then ultimately check whether the recieved data is in error
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern = /^\d{3,5
Tutorials   
Java Spring Hibernate Struts Training why do not required application restart after jsp changes? How to use contentType Attribute in JSP? How to connect to MySQL in JSP? JSP Comment Types with example How to use ajax in jsp? How to access the database from JSP? how to show image as a link which path coming from database jsp netbeans javascript Logos on mail inbox. I want to update the multiple values of database depending on checkbox..? Please help me out.. jsp 18/04/2013 JSTL how to access element added via javascript dynamically using jsp code Electronic spreadsheets are useful in situation An E-mail protocol for storage JSP JSP JSP jsp servlets Exception: com.mysql.jdbc.Driver display data from database on selecting option of dropdownlist display data from database on selecting option of dropdownlist display data from database on selecting option of dropdownlist display data from database on selecting option of dropdownlist Jsp Query run command prompt from jsp program question for c++ please help me how to set up Netbeans for JSP 3 dropdown list from the database using JSP autocompletion in textfield fetching from database in jsp openning the pdf or doc file in same jsp EXT JS tt need coding JSp session time out how to display values from database into table using jsp how to set the class path variable in tomcat ? need help please online examination system mini project problem in writing coding. Please help me. How to read the body content of custom tag? need help...................please please help me jsp coding please. help me image upload Assertions I want to store the value of local variable into Global variable how to create customise shortcut keys in jsp?

Ads

 
Advertisement null

Ads