How to string length through javascripts in PHP

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Jun 2008
Posts: 21
Reputation: gargg321 is an unknown quantity at this point 
Solved Threads: 0
gargg321 gargg321 is offline Offline
Newbie Poster

How to string length through javascripts in PHP

 
0
  #1
Jul 15th, 2008
Hey Guys,
I am new to PHP and know nothing of java scripts. I have to build a web page where user enters login information at the time of registration. I have taken help of a PHP tool to generate the required scripts. Now in that I have to incorporate a functionality to check the password length and give appropiate message if password is too short. I think I could enter this functionality through javascripts but I don't know how. I am attaching the file in which the PHP scripts are written. Please help me out.
Attached Files
File Type: php login_tableadd.php (17.0 KB, 5 views)
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: How to string length through javascripts in PHP

 
0
  #2
Jul 15th, 2008
This is how you get the length of a string.
  1. var stringlen = stringvarname.length;

BTW: its all html when it hits the browser
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 133
Reputation: vicky_rawat is an unknown quantity at this point 
Solved Threads: 17
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: How to string length through javascripts in PHP

 
0
  #3
Jul 15th, 2008
Hi,

Replace the ew_ValidateForm javascript function with
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. function ew_ValidateForm(fobj) {
  2. if (fobj.a_confirm && fobj.a_confirm.value == "F")
  3. return true;
  4. var i, elm, aelm, infix;
  5. var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
  6. for (i=0; i<rowcnt; i++) {
  7. infix = (fobj.key_count) ? String(i+1) : "";
  8. elm = fobj.elements["x" + infix + "_user_name"];
  9. if (elm && !ew_HasValue(elm)) {
  10. if (!ew_OnError(elm, "Please enter required field - User Name"))
  11. return false;
  12. }
  13. elm = fobj.elements["x" + infix + "_password"];
  14. if (elm && !ew_HasValue(elm)) {
  15. if (!ew_OnError(elm, "Please enter required field - Password"))
  16. return false;
  17. }
  18. //Added by vivek Rawat here to check the length of pasword
  19. minlength=6;
  20. if (elm)
  21. {
  22. if(elm.value.length < minlength)
  23. {
  24. alert("Password should have minimum "+minlength+" characters");
  25. return false;
  26. }
  27. }
  28. //end added by vivek rawat
  29. elm = fobj.elements["x" + infix + "_user_id"];
  30. if (elm && !ew_HasValue(elm)) {
  31. if (!ew_OnError(elm, "Please enter required field - User ID"))
  32. return false;
  33. }
  34. elm = fobj.elements["x" + infix + "_user_id"];
  35. if (elm && !ew_CheckInteger(elm.value)) {
  36. if (!ew_OnError(elm, "Incorrect integer - User ID"))
  37. return false;
  38. }
  39. elm = fobj.elements["x" + infix + "_user_access_rights"];
  40. if (elm && !ew_HasValue(elm)) {
  41. if (!ew_OnError(elm, "Please enter required field - User Access Rights"))
  42. return false;
  43. }
  44. }
  45. return true;
  46. }

Check for the code that I have added.
in the block
//Added by vivek Rawat here to check the length of pasword
Vivek Rawat
Keep solving complexities.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 21
Reputation: gargg321 is an unknown quantity at this point 
Solved Threads: 0
gargg321 gargg321 is offline Offline
Newbie Poster

Re: How to string length through javascripts in PHP

 
0
  #4
Jul 15th, 2008
Thanx a ton vicky. The code is working perfectly.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC