Vikhyath_11

w2

Jul 29th, 2024 (edited)
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Program2</title>
  7. </head>
  8. <body>
  9. <form onsubmit="return valid()">
  10. Username(in DAADDAADDD):<input type="text" id="req1">
  11. <input type="submit" value="submit">
  12. </form>
  13. <script>
  14. function valid(){
  15. var usn=document.getElementById("req1").value;
  16. alert(usn);
  17. if(isCorrect(usn)){
  18. return false;
  19. }
  20. return true;
  21. }
  22. function isCorrect(elem1){
  23. expusn=/[0-4]{1}[A-Z]{2}[0-4]{2}[A-Z]{2}[0-9]{3}$/;
  24. if(elem1.length==0){
  25. alert("no usn is entered");
  26. elem1.focus();
  27. return false;
  28. }
  29. else if(!elem1.match(expusn)){
  30. alert("the usn is not in DAADDAADDD format");
  31. elem1.focus();
  32. return false;
  33. }
  34. alert("yes the usn entered is correct");
  35. return true;
  36.  
  37. }
  38. </script>
  39. </body>
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment