943,604 Members | Top Members by Rank

Ad:
Jul 15th, 2008
0

How to string length through javascripts in PHP

Expand Post »
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, 16 views)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gargg321 is offline Offline
21 posts
since Jun 2008
Jul 15th, 2008
0

Re: How to string length through javascripts in PHP

This is how you get the length of a string.
javascript Syntax (Toggle Plain Text)
  1. var stringlen = stringvarname.length;

BTW: its all html when it hits the browser
Reputation Points: 358
Solved Threads: 89
Posting Shark
R0bb0b is offline Offline
986 posts
since Jun 2008
Jul 15th, 2008
0

Re: How to string length through javascripts in PHP

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
Reputation Points: 28
Solved Threads: 19
Junior Poster
vicky_rawat is offline Offline
137 posts
since Jun 2008
Jul 15th, 2008
0

Re: How to string length through javascripts in PHP

Thanx a ton vicky. The code is working perfectly.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gargg321 is offline Offline
21 posts
since Jun 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Problem with javascript code in Mozilla firefox.
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Suggestions on Web Project Topic





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC