Basic Question on passing value to Javascript

Hi

I am fairly new to Ruby (& Sinatra). I have a web form (ERB) where none
of the fields can be blank and I need client side validation to show
fields are empty.

I want to get the value from text box field and pass to javascript to
find out if it is empty. As I realize, server side is getting mixed up
with client side and i am not getting the value passed correctly.

Here is my code-- Can someone please guide (apologize the query is
trivial)

Form1.erb–

Host

<@str = txtHost.value> function validateForm() { var x = '<%= @str %>' if (x == null || x == "") { alert("Host must be filled out"); return false; } }

Maybe this could help you - https://github.com/gazay/gon-sinatra

Greetings Benny

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs