Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sarika
check where is error
1 Answer(s)      6 years and a month ago
Posted in : JSP-Interview Questions



Advertisement
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
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
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
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
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!!!!!!!!!   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
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
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
 

 

 

DMCA.com