Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - form validation
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

form validation

 Post Reply Post Reply
Author
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post Topic: form validation
    Posted: 05 September 2003 at 10:54am

Maybe I overlooked your javascript forum but I could not find one when I browsed the "select forum" dropdown.

I have a long asp page coded to client's spec.
The problem with this page is to determine that a box is blank, the entire form is usually completed first.
They have found that this is cumbersome and frustrating so they have asked me to put a trigger or an event handler that will prevent a user from leaving some textboxes before data is entered into that text box.
I have several onSubmit() javascript codes but they don't solve the problem because the client is still dealing with having to complete entire form before finding that an error exists.
Can someone give me a link or a help on the code that prevents a user from leaving an input textbox until value is entered into that textbox, please?


Thanks for your assistance in advance.

 

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2003 at 11:07am

Hopefully can start you on the way

<html>
<head>
<script language="javascript">
function CheckForEmpty(obj) {
     if (trim(obj.value)=='') {
          alert('Please Complete the Field');
          return false;
     }
     return true;
}
function trim( i_strValue ) {
     return i_strValue.replace(/^[ ]*|[ ]*$/g, '');
}
</script>
</head>
<body>
<form onSubmit="alert('It is OK to post now')">
Enter Data:<br/>
<input type="text" name="Name" onBlur="return CheckForEmpty(this);"/>
<br/><br/>
<input type="submit" value="Post Form"/>
</form>
</body>
</html>

Contribute to the working anarchy we fondly call the Internet
Back to Top
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2003 at 12:01pm

thank you very much.

It doesn't keep the cursor on that input box but atleast it gives the user a message.

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2003 at 12:10pm

i never said "ship it" on that code.. it was just a way of getting you started... its your app, not mine  :-)... you write it

but alas... a simple addition of one line

if (trim(obj.value)=='') {
     alert('Please Complete the Field');
     obj.focus();
     return false;
}

Contribute to the working anarchy we fondly call the Internet
Back to Top
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2003 at 12:53pm

I did add this line: obj.focus();
 and I was just coming back to advise you of that.

Thank you and by the way I didn't try to insinuate that that was a finished product; at least I hope that was not the impression I gave you Sorry if I did.

Thanks again for your help.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.