Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function checkForm()
- {
- preventDefault();
- var nameValue = document.forms["theForm"]["username"].value;
- var passValue = document.forms["theForm"]["password"].value;
- var correctName = false;
- var correctPass = false;
- if(nameValue=="")
- {
- theForm.username.style.backgroundColor = "red";
- }
- if(passValue=="")
- {
- theForm.password.style.backgroundColor = "red";
- }
- if(!nameValue=="")
- {
- theForm.username.style.backgroundColor = "white";
- correctName = true;
- }
- if(!passValue=="")
- {
- theForm.password.style.backgroundColor = "white";
- correctPass = true;
- }
- if (correctName && correctPass)
- {
- //alert("Testtest");
- //clearForm(theForm);
- return this;
- }
- }
- function preventDefault(e)
- {
- if(e && e.preventDefault)//Mozilla
- {
- e.preventDefault();
- }
- if(window.event)//IE
- {
- window.event.returnValue = false;
- }
- }
- function clearForm(ele)
- {
- $(ele).find(':input').each(function()
- {
- switch(this.type)
- {
- case 'select-one':
- case 'password':
- case 'text':
- $(this).val('');
- break;
- case 'radio':
- this.checked = false;
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment