Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //זה במאסטר פייג
- <script type="text/javascript">
- function isEmpty(str)
- {
- return (str.length==0);
- }
- function isValidString(str)
- {
- var badCharStr="$%^&*()_+[]{}<>&";
- for (var i=0;i<str.length;i++)
- {
- for (var j=0;j<badCharStr.length;j++)
- {
- if (str.charAt(i)==badCharStr.charAt(j))
- return false;
- }
- }
- if (str.indexOf("\"")!=-1)
- return false;
- return true;
- }
- function isValidNumber(str) {
- for (var i = 0; i < str.length; i++) {
- if ((str.charAt(i) > '9') || (str.charAt(i) < '0'))
- return false;
- }
- return true;
- }
- function isEmail(str)
- {
- if ((str.split("@").length==2)&&
- (str.indexOf("@")!=0)&&
- (str.indexOf(".")!=0)&&
- (str.lastIndexOf(".") != str.length - 1) &&
- (str.indexOf(".")!=-1)&&
- (str.length>=5) && (str.length<=30))
- return true;
- else
- return false;
- }
- </script>
- //זה ברגיסטר
- <script type="text/javascript">
- function checkForm()
- {
- var msg="";
- if (isEmpty(document.getElementById("uname").value))
- {
- msg += "you must enter username\n";
- }
- else
- {
- if (!(isValidString(document.getElementById("uname").value)))
- {
- msg += "you must enter valid characters in user name\n";
- }
- }
- if (isEmpty(document.getElementById("fname").value))
- {
- msg+="you must enter first-name\n";
- }
- else {
- if (!(isValidString(document.getElementById("fname").value))) {
- msg += "you must enter valid characters in first name\n";
- }
- }
- if (isEmpty(document.getElementById("lname").value))
- {
- msg+="you must enter last-name\n";
- }
- else {
- if (!(isValidString(document.getElementById("lname").value))) {
- msg += "you must enter valid characters in last name\n";
- }
- }
- if (isEmpty(document.getElementById("id").value))
- {
- msg+="you must enter id\n";
- }
- else {
- if (!(isValidNumber(document.getElementById("id").value)))
- {
- msg+="id must be only numbers\n";
- }
- }
- if (isEmpty(document.getElementById("email").value))
- {
- msg+="you must enter email\n";
- }
- else
- {
- if (!isEmail(document.getElementById("email").value))
- {
- msg+="you must enter a valid email adress\n";
- }
- }
- if (isEmpty(document.getElementById("age").value))
- {
- msg+="you must enter age\n";
- }
- else {
- if (!(isValidNumber(document.getElementById("age").value))) {
- msg += "you must enter a number in age\n";
- }
- }
- if (isEmpty(document.getElementById("city").value))
- {
- msg+="you must enter city\n";
- }
- if (isEmpty(document.getElementById("gender").value))
- {
- msg+="you must enter gender\n";
- }
- if (isEmpty(document.getElementById("pass").value))
- {
- msg+="you must enter password\n";
- }
- if (isEmpty(document.getElementById("repass").value))
- {
- msg+="you must repeat password\n";
- }
- else
- {
- if ((document.getElementById("pass").value)!=(document.getElementById("repass").value))
- {
- msg+="passwords are not the same\n";
- }
- }
- if (msg.length!=0)
- {
- alert(msg);
- return false;
- }
- return true;
- }
- </script>
Add Comment
Please, Sign In to add comment